Newer
Older
% Generated by roxygen2: do not edit by hand
Hugo Scherer
committed
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
\name{groupstats}
\alias{groupstats}
Hugo Scherer
committed
\title{Generate descriptive statistics and save to GDX}
Hugo Scherer
committed
groupstats(
filename,
BINDir,
gdxmap,
mapping,
cols,
w,
writegdx = TRUE,
filtern = FALSE
)
groupstats(
filename,
BINDir,
gdxmap,
mapping,
cols,
w,
writegdx = TRUE,
filtern = FALSE
)
}
\arguments{
\item{filename}{Name of the GDX file with BIN data and mappings.}
\item{BINDir}{Directory where the FADN data is located.}
\item{gdxmap}{Name of the set in the GDX file that contains the mapping (e.g. Regs2BINID)}
\item{mapping}{Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")}
\item{cols}{Which columns to derive descriptive statistics from}
\item{w}{Column with the Weights for the weighted mean}
\item{writegdx}{Logical. If `TRUE`, it writes a GDX with the descriptive statistics.}
\item{filtern}{Logical. If `TRUE`, results will be limited to more than 15 observations per variable for reporting}
}
\value{
Hugo Scherer
committed
A tibble `tbl_df`.
A tibble `tbl_df`.
}
\description{
Hugo Scherer
committed
`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'
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'
}
\examples{
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
Hugo Scherer
committed
groupstats('FarmDynRexampledata.gdx',
BINDir="inst/extdata/GAMS/",
gdxmap = 'map2binid',
mapping = 'mapping',
cols = c('a', 'b'),
w='Weight')
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
groupstats('FarmDynRexampledata.gdx',
BINDir="inst/extdata/GAMS/",
gdxmap = 'map2binid',
mapping = 'mapping',
cols = c('a', 'b'),
w='Weight')
}
\seealso{
Hugo Scherer
committed
\itemize{
\item{\code{\link{summary]}}}{summary statistics}
\item{\code{\link[psych]{describe}}}{Descriptive statistics}
\item{\code{\link[gdxrrw]{wgdx}}}{Write R data to GDX}
\item{\code{\link[gdxrrw]{wgdx.lst}}}{Write multiple symbols to GDX}
\item{\code{\link[tidyr]{pivot_longer}}}{Make dataframes longer}
}
\item{\code{\link{summary}}}{summary statistics}
\item{\code{\link[psych]{describe}}}{Descriptive statistics}
\item{\code{\link[gdxrrw]{wgdx}}}{Write R data to GDX}
\item{\code{\link[gdxrrw]{wgdx.lst}}}{Write multiple symbols to GDX}
\item{\code{\link[tidyr]{pivot_longer}}}{Make dataframes longer}
}
}