--- Job fdnl.gms Start 10/07/22 15:27:43 40.1.1 23eb37fb WEX-WEI x86 64bit/MS Windows
--- Applying:
C:\GAMS\40\gmsprmNT.txt
--- GAMS Parameters defined
Input C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gms
PageSize 0
ScrDir C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\225a\
SysDir C:\GAMS\40\
LogOption 3
ErrMsg 1
ErrorLog 99
IDE 1
LstTitleLeftAligned 1
Licensee: Large MUD - 20 User License S220111|0002AN-WIN
Wageningen Economic Research DC8271
C:\GAMS\40\gamslice.txt
License Admin: Hans Jonker, hans.jonker@wur.nl
Processor information: 1 socket(s), 4 core(s), and 8 thread(s) available
GAMS 40.1.1 Copyright (C) 1987-2022 GAMS Development. All rights reserved
--- Starting compilation
--- fdnl.gms(1) 2 Mb
--- call csv2gdx fdnl.csv id='p_farmData_NL' index=2,3,4 useHeader=Y colCount=5 value=lastCol
No errors, CSV2GDX time = 32ms
--- fdnl.gms(12) 2 Mb
--- GDXin=C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gdx
--- GDX File ($gdxIn) C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gdx
--- fdnl.gms(25) 3 Mb
--- Starting execution: elapsed 0:00:00.589
--- fdnl.gms(21) 4 Mb
--- GDX File (execute_unload) C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gdx
*** Status: Normal completion
--- Job fdnl.gms Stop 10/07/22 15:27:43 elapsed 0:00:00.592
GAMS 40.1.1 23eb37fb Aug 16, 2022 WEX-WEI x86 64bit/MS Windows - 10/11/22 11:25:18 Page 1
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n
2 Set
3 items 'set of fake items'
4 all_binid 'fake id numbers'
5 * mapping 'fake mapping used'
6 * map2binid 'fake mapping to fake bin id'
7 * varias 'fake variables used'
8 year 'fake years'
9 items2 'items of fdnl';
10
11
GDXIN C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gdx
--- LOAD all_binid = 2:Dim1
--- LOAD year = 3:Dim2
--- LOAD items2 = 4:Dim3
16
17 Parameter p_farmData_NL(all_binid, year, items2) 'Fake Random farmData NL';
--- LOAD p_farmData_NL = 1:p_farmData_NL
20
21 execute_unload "fdnl.gdx"
22 all_binid
23 items2
24 year
25 p_farmData_NL
GAMS 40.1.1 23eb37fb Aug 16, 2022 WEX-WEI x86 64bit/MS Windows - 10/11/22 11:25:18 Page 2
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Include File Summary
SEQ GLOBAL TYPE PARENT LOCAL FILENAME
1 1 INPUT 0 0 C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gms
2 1 CALL 1 1 csv2gdx fdnl.csv id='p_farmData_NL' index=2,3,4 useHeader=Y colCount=5 value=lastCol
3 12 GDXIN 1 12 C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gdx
COMPILATION TIME = 0.359 SECONDS 3 MB 40.1.1 23eb37fb WEX-WEI
GAMS 40.1.1 23eb37fb Aug 16, 2022 WEX-WEI x86 64bit/MS Windows - 10/11/22 11:25:18 Page 3
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
E x e c u t i o n
EXECUTION TIME = 0.000 SECONDS 4 MB 40.1.1 23eb37fb WEX-WEI
USER: Large MUD - 20 User License S220111|0002AN-WIN
Wageningen Economic Research DC8271
License for teaching and research at degree granting institutions
**** FILE SUMMARY
Input C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.gms
Output C:\FARMDYNDATA\R\DynR\inst\extdata\GAMS\fdnl.lst
B 3 C o m p i l a t i o n
B 31 Include File Summary
B 44 E x e c u t i o n
"","all_binid","grouping"
"1","28","E"
"2","80","E"
"3","150","E"
"4","101","E"
"5","111","E"
"6","137","E"
"7","133","E"
"8","166","E"
"9","144","E"
"10","132","E"
"11","98","F"
"12","103","F"
"13","90","F"
"14","70","F"
"15","79","F"
"16","116","F"
"17","14","F"
"18","126","F"
"19","62","F"
"20","4","F"
"21","178","G"
"22","149","G"
"23","40","G"
"24","93","G"
"25","122","G"
"26","181","G"
"27","66","G"
"28","123","G"
"29","48","G"
"30","108","G"
"31","131","G"
"32","87","G"
"33","41","G"
"34","115","G"
"35","72","G"
"36","42","G"
"37","43","G"
"38","2","G"
"39","117","G"
"40","173","G"
"41","49","G"
"42","102","G"
"43","51","G"
"44","134","G"
"45","147","G"
"46","143","G"
"47","57","G"
"48","136","G"
"49","26","G"
"50","160","G"
"51","8","G"
"52","96","G"
"53","22","G"
"54","35","G"
"55","155","G"
"56","157","G"
"57","86","G"
"58","141","G"
"59","10","G"
"60","55","G"
"61","135","H"
"62","120","H"
"63","109","H"
"64","25","H"
"65","3","H"
"66","83","H"
"67","50","H"
"68","180","H"
"69","175","H"
"70","156","H"
"71","174","H"
"72","20","H"
"73","162","H"
"74","63","H"
"75","71","H"
"76","61","H"
"77","140","H"
"78","145","H"
"79","170","H"
"80","184","H"
"81","27","H"
"82","76","H"
"83","153","H"
"84","159","H"
"85","60","H"
"86","65","H"
"87","36","H"
"88","187","H"
"89","19","H"
"90","9","H"
"91","30","H"
"92","114","H"
"93","17","H"
"94","167","H"
"95","58","H"
"96","6","H"
"97","85","H"
"98","91","H"
"99","32","H"
"100","77","H"
"101","95","H"
"102","161","H"
"103","92","H"
"104","164","H"
"105","185","H"
"106","53","H"
"107","186","H"
"108","11","H"
"109","176","H"
"110","179","H"
"111","21","H"
"112","152","H"
"113","119","H"
"114","177","H"
"115","151","H"
"116","99","H"
"117","127","H"
"118","46","H"
"119","165","H"
"120","29","H"
"121","130","I"
"122","16","I"
"123","38","I"
"124","24","I"
"125","97","I"
"126","73","I"
"127","75","I"
"128","183","I"
"129","105","I"
"130","128","I"
"131","15","I"
"132","82","I"
"133","113","I"
"134","171","I"
"135","23","I"
"136","59","I"
"137","52","I"
"138","7","I"
"139","74","I"
"140","104","I"
"141","69","I"
"142","78","I"
"143","139","I"
"144","94","I"
"145","84","I"
"146","56","I"
"147","100","I"
"148","34","I"
"149","37","I"
"150","88","I"
"151","125","I"
"152","138","I"
"153","182","I"
"154","110","I"
"155","168","I"
"156","64","I"
"157","172","I"
"158","47","I"
"159","45","I"
"160","121","I"
"161","118","I"
"162","124","I"
"163","158","I"
"164","163","I"
"165","5","I"
"166","67","I"
"167","169","I"
"168","129","I"
"169","107","I"
"170","68","I"
"171","44","I"
"172","142","I"
"173","33","I"
"174","12","I"
"175","106","I"
"176","1","I"
"177","18","I"
"178","112","I"
"179","13","I"
"180","31","I"
"181","89","I"
"182","39","I"
"183","81","I"
"184","154","I"
"185","148","I"
"186","54","I"
"187","146","I"
"188","dummy","I"
File added
$call csv2gdx map2id.csv id='map2binid' index=2,3 useHeader=Y colCount=3
Set
mapping 'set of fake mapping'
all_binid 'fake id numbers'
map2binid 'map2id';
$gdxIn map2id.gdx
$load all_binid = Dim1
$load mapping = Dim2
$load map2binid
$gdxIn
execute_unload "map2id.gdx"
all_binid
mapping
map2binid
\ No newline at end of file
man/Modes.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{Modes}
\alias{Modes}
\title{Retrieve mode of vector}
\usage{
Modes(x)
}
\arguments{
\item{x}{vector from which to retrieve the mode from.}
}
\value{
same class as 'x'.
}
\description{
This function returns the mode of a vector. If the vector contains a character or factor, the most common character/factor is returned. Numbers written as characters will be compatible with non-character numbers (i.e. doubles/numeric), but the function returns a character.
}
\examples{
Modes(x = c(1, 1, 3, 0, 2, 4, 2, 1, 5, 2, 1))
Modes(x = c('a','b', 'c', 'a', 'c', 'a'))
Modes(x = c('a', 2, 'x', 7895, 1, '2', 't', 2, 1))
}
\seealso{
[tabulate()]
}
man/fd2gui.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{fd2gui}
\alias{fd2gui}
\title{FarmDynR example data}
\format{
Objects of class `tbl_df`
}
\usage{
data(fd2gui); data(fdnl); data(gdxmapping)
}
\description{
Random fake data used to play with the FarmDynR package.
}
\examples{
data(fd2gui)
data(fdnl)
data(gdxmapping)
}
\keyword{FarmDynR}
\keyword{datasets,}
% Generated by roxygen2: do not edit by hand
% 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)
}
\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")}
}
\value{
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.
}
\examples{
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}
}
}
man/gdxreshape.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% 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
)
}
\arguments{
\item{inDF}{wide dataframe.}
\item{symDim}{wide dataframe.}
\item{symName}{wide dataframe.}
\item{tName}{wide dataframe.}
\item{gdxName}{wide dataframe.}
\item{setsToo}{wide dataframe.}
\item{order}{wide dataframe.}
\item{setNames}{wide dataframe.}
}
\value{
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.
}
\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}
}
}
man/groupstats.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{groupstats}
\alias{groupstats}
\title{Reshape from wide to long and save to GDX}
\usage{
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{
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'
}
\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')
}
\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}
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{runFarmDynfromBatch}
\alias{runFarmDynfromBatch}
\title{Execute FarmDyn}
\usage{
runFarmDynfromBatch(FarmDynDir, IniFile, XMLFile, BATCHDir, BATCHFile)
}
\arguments{
\item{FarmDynDir}{Directory where FarmDyn is located}
\item{IniFile}{Name of the IniFile}
\item{XMLFile}{Name of the XML file}
\item{BATCHDir}{Directory where the .batch file is located}
\item{BATCHFile}{Name of the .batch file}
}
\value{
Executes FarmDyn from R
}
\description{
`runFarmDynfromBatch()` does as it says in the function.
}
\examples{
TODO write example
}
\seealso{
*Globiom?
}
man/samplr.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{samplr}
\alias{samplr}
\title{Reshape from wide to long and save to GDX}
\usage{
samplr(filename, BINDir, gdxmap, mapping, writegdx = TRUE)
}
\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{writegdx}{Logical. If `TRUE`, it writes a GDX with the descriptive statistics.}
}
\value{
A tibble `tbl_df`.
}
\description{
`samplr()` 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'
samplr('FarmDynRexampledata.gdx',
&BINDir="inst/extdata/GAMS/",
&gdxmap = 'map2binid',
&mapping = 'mapping',
&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}
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FarmDynR.R
\name{str_line_replace}
\alias{str_line_replace}
\alias{str_firstLine_replace}
\alias{str_lastLine_replace}
\title{Replace first or last line in strings}
\usage{
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{
\item{str}{String with pattern to make replacement}
\item{pattern}{Regular expression to replace}
\item{replacement}{What to replace the pattern with}
\item{which}{which one? first, last, all or the poles (first AND last)}
}
\value{
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()`.
}
\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')
}
\seealso{
[stringr::str_replace()]
}
man/writeBatch.Rd 0 → 100644
% Generated by roxygen2: do not edit by hand
% 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)
}
\arguments{
\item{FarmDynDir}{Directory where FarmDyn is located}
\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
}
\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.
}
\examples{
TODO write example
}
\seealso{
\code{\link[FarmDynR]{runFarmDynfromBatch}}
}