% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{gdxbinwider}
\alias{gdxbinwider}
\title{Join BIN data together, make joined dataset wider, and group by a mapping}
\usage{
gdxbinwider(filename, BINDir, gdxmap, mapping)
gdxbinwider(filename, BINDir, gdxmap, mapping)
}
\arguments{
......@@ -18,37 +16,11 @@ gdxbinwider(filename, BINDir, gdxmap, mapping)
\item{mapping}{Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")}
}
\value{
A tibble `tbl_df`.
A tibble `tbl_df`.
A tibble `tbl_df`
}
\description{
The `gdxbinwider()` function takes in a GDX file with BIN data as parameters p_farmData_NL and p_farmData2GUI, and a mapping as a set.
Then the data is widened, and the output is a tibble.
This function has been conceived with the Dutch FADN in mind, please use `fadn2fd()` for EU FADN data.
The `gdxbinwider()` function takes in a GDX file with BIN data as parameters p_farmData_NL and p_farmData2GUI, and a mapping as a set.
Then the data is widened, and the output is a tibble.
}
\examples{
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
gdxbinwider(datafile, BINDir, 'map2binid', 'mapping')
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
gdxbinwider(datafile, BINDir, 'map2binid', 'mapping')
}
\seealso{
\itemize{
\item{\code{\link[gdxrrw]{rgdx.param}}}{Load GDX parameters}
\item{\code{\link[gdxrrw]{rgdx.set}}}{Load GDX sets}
\item{\code{\link[tidyr]{pivot_wider}}}{Make dataframes wider}
}
\itemize{
\item{\code{\link[gdxrrw]{rgdx.param}}}{Load GDX parameters}
\item{\code{\link[gdxrrw]{rgdx.set}}}{Load GDX sets}
\item{\code{\link[tidyr]{pivot_wider}}}{Make dataframes wider}
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{gdxload}
\alias{gdxload}
\title{Load from GDX}
\usage{
gdxload(
filename,
symbol = c("set", "param", "scalar"),
symName,
names = NULL,
...
)
gdxload(
filename,
symbol = c("set", "param", "scalar"),
......@@ -32,20 +24,12 @@ gdxload(
\item{...}{Arguments to be passed to gdxrrw::rgdx(...)}
}
\value{
A dataframe
A dataframe
}
\description{
`gdxload()` is a wrapper for gdxrrw::rgdx. It fixes the issue of having all UELs as factor levels for variables for which they do not belong.
`gdxload()` is a wrapper for gdxrrw::rgdx. It fixes the issue of having all UELs as factor levels for variables for which they do not belong.
}
\seealso{
*gdxrrw::rgdx.set()
*gdxrrw::rgdx.param()
*gdxrrw::rgdx.scalar()
*gdxrrw::rgdx.set()
*gdxrrw::rgdx.param()
*gdxrrw::rgdx.scalar()
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{gdxreshape}
\alias{gdxreshape}
\title{Reshape from wide to long and save to GDX}
\usage{
gdxreshape(
inDF,
symDim,
symName = NULL,
tName = "time",
gdxName = NULL,
setsToo = TRUE,
order = NULL,
setNames = NULL
)
gdxreshape(
inDF,
symDim,
......@@ -29,45 +18,28 @@ gdxreshape(
\arguments{
\item{inDF}{wide dataframe.}
\item{symDim}{wide dataframe.}
\item{symDim}{Dimensions of symbol}
\item{symName}{wide dataframe.}
\item{symName}{Symbol name}
\item{tName}{wide dataframe.}
\item{tName}{"Time"}
\item{gdxName}{wide dataframe.}
\item{gdxName}{Name of gdx file}
\item{setsToo}{wide dataframe.}
\item{setsToo}{if sets too}
\item{order}{wide dataframe.}
\item{order}{order of data}
\item{setNames}{wide dataframe.}
\item{setNames}{name of sets}
}
\value{
A tibble `tbl_df`.
A tibble `tbl_df`.
}
\description{
`gdxreshape()` formats the data to be saved in GDX into long format. It is imported from the gdxrrw package with a few improvements for performance and usability, since there is a risk of it being removed from the gdxrrw package in the future.
We would like to thank the R GAMS team for this useful function.
`gdxreshape()` formats the data to be saved in GDX into long format. It is imported from the gdxrrw package with a few improvements for performance and usability, since there is a risk of it being removed from the gdxrrw package in the future.
We would like to thank the R GAMS team for this useful function.
}
\examples{
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
gdxbinwider(datafile, BINDir, 'map2binid', 'mapping')
}
\seealso{
\itemize{
\item{\code{\link[gdxrrw]{wgdx]}}}{Write R data to GDX}
\item{\code{\link[gdxrrw]{wgdx.lst]}}}{Write multiple symbols to GDX}
\item{\code{\link[gdxrrw]{wgdx.reshape]}}}{Write multiple symbols to GDX}
\item{\code{\link[tidyr]{pivot_longer]}}}{Make dataframes longer}
}
\itemize{
\item{\code{\link[gdxrrw]{wgdx}}}{Write R data to GDX}
\item{\code{\link[gdxrrw]{wgdx.lst}}}{Write multiple symbols to GDX}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{groupstats}
\alias{groupstats}
\title{Generate descriptive statistics and save to GDX}
\usage{
groupstats(
filename,
BINDir,
gdxmap,
mapping,
cols,
w,
writegdx = TRUE,
filtern = FALSE
)
groupstats(
filename,
BINDir,
......@@ -44,15 +33,9 @@ groupstats(
\item{filtern}{Logical. If `TRUE`, results will be limited to more than 15 observations per variable for reporting}
}
\value{
A tibble `tbl_df`.
A tibble `tbl_df`.
}
\description{
`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
......@@ -62,14 +45,6 @@ region based on the individual farm data. When `writegdx` is `TRUE`, it writes t
\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')
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
groupstats('FarmDynRexampledata.gdx',
BINDir="inst/extdata/GAMS/",
gdxmap = 'map2binid',
......@@ -78,14 +53,6 @@ groupstats('FarmDynRexampledata.gdx',
w='Weight')
}
\seealso{
\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}
}
\itemize{
\item{\code{\link{summary}}}{summary statistics}
\item{\code{\link[psych]{describe}}}{Descriptive statistics}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{runFarmDynfromBatch}
\alias{runFarmDynfromBatch}
\title{Execute FarmDyn}
\usage{
runFarmDynfromBatch(FarmDynDir, IniFile, XMLFile, BATCHDir, BATCHFile)
runFarmDynfromBatch(FarmDynDir, IniFile, XMLFile, BATCHDir, BATCHFile)
}
\arguments{
......@@ -17,22 +15,14 @@ runFarmDynfromBatch(FarmDynDir, IniFile, XMLFile, BATCHDir, BATCHFile)
\item{BATCHDir}{Directory where the .batch file is located}
\item{BATCHFile}{Name of the .batch file}
\item{BATCHFile}{Name of the .batch file.}
}
\value{
Executes FarmDyn from R
Executes FarmDyn from R
}
\description{
`runFarmDynfromBatch()` does as it says in the function.
`runFarmDynfromBatch()` makes it possible to run FarmDyn from R using the batch file
}
\examples{
TODO write example
}
\seealso{
*Globiom?
NULL
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{str_line_replace}
\alias{str_line_replace}
\alias{str_firstLine_replace}
......@@ -15,17 +15,6 @@ str_line_replace(
str_firstLine_replace(str, pattern, replacement)
str_lastLine_replace(str, pattern, replacement)
str_line_replace(
str,
pattern,
replacement,
which = c("first", "last", "poles", "all")
)
str_firstLine_replace(str, pattern, replacement)
str_lastLine_replace(str, pattern, replacement)
}
\arguments{
......@@ -38,17 +27,9 @@ str_lastLine_replace(str, pattern, replacement)
\item{which}{which one? first, last, all or the poles (first AND last)}
}
\value{
string
string
}
\description{
These functions serve to change the first or last line of strings which match a specific pattern (regex).
`str_firstLine_replace()` replaces the first line that matches the pattern.
`str_lastLine_replace()` replaces the last line that matches the pattern
They are useful, for example, when reading a text file with many lines and you want to preserve the lines of that text file.
When `which='all'`, it is a wrapper for `stringr::str_replace()`.
These functions serve to change the first or last line of strings which match a specific pattern (regex).
`str_firstLine_replace()` replaces the first line that matches the pattern.
`str_lastLine_replace()` replaces the last line that matches the pattern
......@@ -57,19 +38,8 @@ When `which='all'`, it is a wrapper for `stringr::str_replace()`.
}
\examples{
somelines <- c('AAAAA', 'textytext', 'BBBBB', 'AAAAA', 'writingwriting', 'AAAAA', 'etc', 'etc', 'BBBBB')
str_firstLine_replace(somelines, 'AAAAA', 'changedfirstline')
str_lastLine_replace(somelines, 'AAAAA', 'changedlastline')
str_line_replace(somelines, 'AAAAA', 'changedpoles', which='poles')
str_line_replace(somelines, 'AAAAA', 'changedall', which='all')
somelines <- c('AAAAA', 'textytext', 'BBBBB', \n
'AAAAA', 'writingwriting', 'AAAAA', \n
somelines <- c('AAAAA', 'textytext', 'BBBBB', \\n
'AAAAA', 'writingwriting', 'AAAAA', \\n
'etc', 'etc', 'BBBBB')
str_firstLine_replace(somelines, 'AAAAA', 'changedfirstline')
......@@ -82,7 +52,5 @@ str_line_replace(somelines, 'AAAAA', 'changedall', which='all')
}
\seealso{
[stringr::str_replace()]
[stringr::str_replace()]
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{updateFarmData}
\alias{updateFarmData}
\title{Reshape from wide to long and save to GDX
Create sample farms}
\usage{
updateFarmData(
filename,
BINDir,
gdxmap,
mapping,
writegdx = TRUE,
cptcoeffs = FALSE,
farmchars = NULL,
cptcoeffsxl = NULL
)
updateFarmData(
filename,
BINDir,
......@@ -45,14 +34,9 @@ updateFarmData(
\item{cptcoeffsxl}{Location of the CPT coefficients excel file}
}
\value{
A tibble `tbl_df`.
A tibble `tbl_df`.
}
\description{
`updateFarmData()` creates sample farms by aggregating data based on the weighted mean and the selected mapping for use in FarmDyn.
For non-numerical globals, it summarises based on the mode using the `Modes()` function. When `writegdx` is `TRUE`, it writes the GDX in the format 'farmData_(mapping).gdx'.
This function has been conceived with the Dutch FADN in mind, please use `fadn2fd()` for EU FADN data.
`updateFarmData()` creates sample farms by aggregating data based on the weighted mean and the selected mapping for use in FarmDyn.
......@@ -61,13 +45,6 @@ For non-numerical globals, it summarises based on the mode using the `Modes()` f
\examples{
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
updateFarmData('FarmDynRexampledata.gdx',
&BINDir="inst/extdata/GAMS/",
&gdxmap = 'map2binid',
&mapping = 'mapping',
&w='Weight')
BINDir <- "inst/extdata/GAMS"
datafile <- 'FarmDynRexampledata.gdx'
updateFarmData('FarmDynRexampledata.gdx',
&BINDir="inst/extdata/GAMS/",
&gdxmap = 'map2binid',
......@@ -75,15 +52,6 @@ updateFarmData('FarmDynRexampledata.gdx',
&w='Weight')
}
\seealso{
\itemize{
\item{\code{\link[FarmDynR]{gdxbinwider}}}{Widens BIN data directly from GDX}
\item{\code{\link[FarmDynR]{gdxreshape}}}{Lengthens data and saves to GDX}
\item{\code{\link[gdxrrw]{wgdx}}}{Write R data to GDX}
\item{\code{\link[gdxrrw]{wgdx.lst}}}{Write multiple symbols to GDX}
\item{\code{\link[dplyr]{summarise}}}{Make dataframes longer}
\item{\code{\link{weighted.mean]}}}{Calculates weighted mean}
}
\itemize{
\item{\code{\link[FarmDynR]{gdxbinwider}}}{Widens BIN data directly from GDX}
\item{\code{\link[FarmDynR]{gdxreshape}}}{Lengthens data and saves to GDX}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
% Please edit documentation in R/FarmDynR.R
\name{writeBatch}
\alias{writeBatch}
\title{Write batch file for batch file execution mode in FarmDyn}
\usage{
writeBatch(FarmDynDir, mapping, farmIds)
writeBatch(FarmDynDir, mapping, farmIds)
}
\arguments{
......@@ -16,23 +14,16 @@ writeBatch(FarmDynDir, mapping, farmIds)
\item{farmIds}{Individual farm Identifiers. This is usually the aggregation (mapping) of your p_farmData file. Whereas here the mapping is just the name of the aggregation, farmIds is a vector of the names of the different farm samples made. For example, if mapping = NUTS0, then famrIds would be AT, BE, BG... etc.}
}
\value{
Writes batch file necessary to run FarmDyn
Writes batch file necessary to run FarmDyn
}
\description{
This function writes the batch file for you. It directly takes the necessary information from runInc.gms in FarmDyn, so the GUI
settings remain the same as you have set them.
This function writes the batch file for you. It directly takes the necessary information from runInc.gms in FarmDyn, so the GUI
settings remain the same as you have set them.
}
\examples{
TODO write example
NULL
}
\seealso{
\code{\link[FarmDynR]{runFarmDynfromBatch}}
\code{\link[FarmDynR]{runFarmDynfromBatch}}
}