This 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
)

Arguments

filename

Name of the GDX file with BIN data and mappings.

BINDir

Directory where the FADN data is located.

gdxmap

Name of the set in the GDX file that contains the mapping (e.g. Regs2BINID)

mapping

Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")

cols

Which columns to derive descriptive statistics from

w

Column with the Weights for the weighted mean

writegdx

Logical. If `TRUE`, it writes a GDX with the descriptive statistics.

filtern

Logical. If `TRUE`, results will be limited to more than 15 observations per variable for reporting

Value

A tibble `tbl_df`.

See also

Examples

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