groupstats.RdThis function has been conceived with the Dutch FADN in mind, please use `fd_dec()` for EU FADN data.
`groupstats()` returns descriptive statistics per group based on the mapping given. For example, if your mapping is 'regions', this function will give you the weighted mean, median, min, max, number of observations per variable for each region based on the individual farm data. When `writegdx` is `TRUE`, it writes the GDX in the format 'farmStats_(mapping).gdx'
groupstats(
filename,
BINDir,
gdxmap,
mapping,
cols,
w,
writegdx = TRUE,
filtern = FALSE
)Name of the GDX file with BIN data and mappings.
Directory where the FADN data is located.
Name of the set in the GDX file that contains the mapping (e.g. Regs2BINID)
Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")
Which columns to derive descriptive statistics from
Column with the Weights for the weighted mean
Logical. If `TRUE`, it writes a GDX with the descriptive statistics.
Logical. If `TRUE`, results will be limited to more than 15 observations per variable for reporting
A tibble `tbl_df`.
summarysummary statistics
describeDescriptive statistics
wgdxWrite R data to GDX
wgdx.lstWrite multiple symbols to GDX
pivot_longerMake dataframes longer
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
groupstats('FarmDynRexampledata.gdx',
BINDir="inst/extdata/GAMS/",
gdxmap = 'map2binid',
mapping = 'mapping',
cols = c('a', 'b'),
w='Weight')
#> Error in rgdx(gdxName, list(name = symName, compress = compress, ts = ts), squeeze = squeeze, useDomInfo = useDomInfo): GDX file 'inst/extdata/GAMS//FarmDynRexampledata.gdx' not found