Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
output: rmarkdown::github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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.
<!-- badges: start -->
<!-- badges: end -->
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
Hugo Scherer
committed
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'...)
```