man/scen_diff.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{scen_diff}
\alias{scen_diff}
\title{Calculates the relative difference of the reference and the scenarios in a new column}
\usage{
scen_diff(data, vars_to_diff)
}
\arguments{
\item{data}{A dataframe}
\item{vars_to_diff}{A vector with the names of the variables to calculate the difference}
}
\value{
A dataframe with the new columns
}
\description{
Calculates the relative difference of the reference and the scenarios in a new column
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
\name{str_line_replace}
\alias{str_line_replace}
\alias{str_firstLine_replace}
......@@ -15,6 +15,17 @@ 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{
......@@ -27,9 +38,17 @@ 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
......@@ -38,6 +57,17 @@ 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', 'AAAAA', 'writingwriting', 'AAAAA', 'etc', 'etc', 'BBBBB')
str_firstLine_replace(somelines, 'AAAAA', 'changedfirstline')
......@@ -50,5 +80,7 @@ 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.R
% Please edit documentation in R/FarmDynR backup.R, R/FarmDynR.R
\name{updateFarmData}
\alias{updateFarmData}
\title{Reshape from wide to long and save to GDX}
\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,
......@@ -33,15 +45,27 @@ 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'.
`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'.
}
\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',
......@@ -49,6 +73,15 @@ 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}
......
man/vars_dump.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{vars_dump}
\alias{vars_dump}
\title{Load variables from dump gdx files and return a data.table}
\usage{
vars_dump(res_fold, varname, scen_name)
}
\arguments{
\item{res_fold}{Path to the folder where the gdx files are}
\item{varname}{Name of the variable to load}
\item{scen_name}{Name of the scenarios to load}
}
\value{
A data.table with the variable
}
\description{
Load variables from dump gdx files and return a data.table
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
% Please edit documentation in R/FarmDynR backup.R, 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{
......@@ -12,16 +14,25 @@ writeBatch(FarmDynDir, mapping, farmIds)
\item{mapping}{Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")}
}
\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
TODO write example
}
\seealso{
\code{\link[FarmDynR]{runFarmDynfromBatch}}
\code{\link[FarmDynR]{runFarmDynfromBatch}}
}