--- output: rmarkdown::github_document --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) ``` # FarmDynR Developed by Hugo Scherer and Marc Müller at Wageningen Economic Research. The goal of FarmDynR is to give the user the ability to aggregate FADN Data from GDX files to create representative farms for any grouping, generate descriptive statistics, and to run FarmDyn from R. ## Requirements This package requires that you have GAMS and FarmDyn installed. Additionally, the package imports from: - gdxrrw (remember to load GAMS with `igdx()` with the path to your version of GAMS) - tidyverse It also suggests: - stringr ## Installation You can install the development version of FarmDynR like so: ``` r install.packages('https://gitlab.iiasa.ac.at/mind-step/FarmDynR') ``` ## Workflow 1. Create GDX files with the mappings, global settings per farm, farm data, and weights 2. Use `updateFarmData()` to create sample farms based on your selected mapping 3. Write batch file with `writeBatch()` and run FarmDyn with `runFarmDynfromBatch()` using the created batch file - Optional: Create descriptive statistics for reporting with `groupstats()` ## Example This is a basic example which shows you how to solve a common problem: ```{r example, eval=FALSE, include=TRUE} library(FarmDynR) ## basic example code groupstats(filename = 'FarmDynRexampledata.gdx', BINDir = 'inst/extdata/GAMS/', gdxmap = gdxmapping, mapping = mapping, cols = c(a,b,c), w = Weight, writegdx = FALSE, filtern = FALSE) # Bad, won't work groupstats(filename = 'FarmDynRexampledata.gdx', BINDir = 'inst/extdata/GAMS/', gdxmap = 'gdxmapping', mapping = 'mapping', cols = c('a','b','c'), w = 'Weight', writegdx = FALSE, filtern = FALSE) # Good, there can also be more than one mapping with c('mapping1', 'mapping2'...) ```