Description: This package allows the user to run FarmDyn from R and includes useful functions such as:
Modes() to retrieve the mode of any set of numbers or characters in a dataset or vector, and
groupstats() to generate descriptive statistics used for reporting based on a grouping.
It also writes gdx files for groupstats() and samplr(), and includes a faster version of gdxrrw:wgdx.reshape() called gdxreshape()
Description: This package allows the user to run FarmDyn from R, create sample farms from FADN data for use in FarmDyn, and includes useful functions to work with the results from FarmDyn.
# Pivotting to long because if the operations are done in wide format it will produce duplicates that will be corrected with '.1' at the end (or another nr depending on how many times it is duplicated)
# with added benefits that the aprod/aarea are also in long format and that when pivotting to wide again a sum function can be added, so everything that belongs to the same FarmDyn crop category can be summed up
colnames(aprod)[2]<-"item1"
# Some columns are integers so it will throw a warning
@@ -20,12 +20,15 @@ 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.
The goal of FarmDynR is to give the user the ability to aggregate FADN data to create representative farms for any grouping available, 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
- readr
- dplyr
- tidyr
- readxl
It also suggests:
- stringr
...
...
@@ -39,20 +42,36 @@ You can install the development version of FarmDynR like so:
```
## 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
The workflow for this package is as follows:
1. Read the FADN data into R
2. Run `fadn2fd()` with the FADN data, farmbranch desired, the mapping and the option to save GDX files based on the mapping
- Yields will be calculated and the FADN data will be prepared
- Outliers are removed
3. Write batch file with `writeBatch()` and run FarmDyn with `runFarmDynfromBatch()` using the created batch file
- Optional: Create descriptive statistics for reporting with `groupstats()`
- Optional: Create descriptive statistics for reporting with `fd_desc()` with the farmbranch
## Example
This is a basic example which shows you how to solve a common problem:
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'...)
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.
data to create representative farms for any grouping available, 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
with `igdx()` with the path to your version of GAMS) - readr - dplyr -
tidyr - readxl
It also suggests: - stringr
...
...
@@ -31,23 +32,35 @@ You can install the development version of FarmDynR like so:
## 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()`
The workflow for this package is as follows: 1. Read the FADN data into
R 2. Run `fadn2fd()` with the FADN data, farmbranch desired, the mapping
and the option to save GDX files based on the mapping - Yields will be
calculated and the FADN data will be prepared - Outliers are removed 3.
Write batch file with `writeBatch()` and run FarmDyn with
`runFarmDynfromBatch()` using the created batch file - Optional: Create
descriptive statistics for reporting with`fd_desc()` with the
farmbranch
## Example
This is a basic example which shows you how to solve a common problem:
``` r
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'...)