GitLab at IIASA

README.md 1.74 KiB
Newer Older

<!-- README.md is generated from README.Rmd. Please edit that file -->

# 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 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) - readr - dplyr -
tidyr - readxl

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

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
# Read in FADN data
fadn <- read_fadn("path/to/fadn/data")

# Create mapping
mapping <- list(c("NUTS0", "misc%OrganicCode"), "NUTS0", "NUTS2")

# Create FarmDyn data
fd_data <- fadn2fd(fadn, "Dairy", mapping, save_gdx = FALSE)

# Write batch file
writeBatch("path/to/FarmDyn", mapping, farmIds)

# Run FarmDyn
runFarmDynfromBatch("path/to/batch/file")

# Create descriptive statistics
fd_desc(fd_data)