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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
title: "The FSS package - use case number 1"
author: Sebastian Neuenfeldt
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
word_document:
reference_docx: "D:/public/neuenfeldt/MIND_STEP/git/MIND STEP - kind of template.docx"
---
<!-- 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%" -->
<!-- ) -->
<!-- ``` -->
# The FSS package
<!-- badges: start -->
<!-- badges: end -->
The goal of the FSS package is to provide some functions to analyse (German) Farm Structure Survey (FSS) data.
## Installation
You can install the GitLab version of FSS from [GitLab](https://git-dmz.thuenen.de/neuenfeldt/fss) with:
``` {r}
# devtools::install_git("https://git-dmz.thuenen.de/neuenfeldt/fss") -->
```
## Example
### Load FSS package
```{r}
library(FSS)
```
### Test a function
Here we will test one of the provided functions: `generateFakeFSSData_DE()`. We generate some basic variables, which are automatically produced. We set an additional variable to
be generated, namely C0300. The variable will be a continuous variable.
```{r}
FSS_data_DE <- generateFakeFSSData_DE(C0codes = "C0300")
```
### Add a specific categorical variable
No we will add a specific variable, i.e. a categorical variable if a farm is an organic farm. This will be randomly distributed. The probability of a farm to be organic is 20%.
```{r, message=FALSE}
library(tidyverse)
FSS_data_DE <- FSS_data_DE %>%
mutate(C0501=sample(c(0,1),
size = nrow(FSS_data_DE),
replace = TRUE,
prob = c(0.8,0.2)))
```
### Some analysis
After that we analyse the data regarding the number of farms that are organic (C0501) for each year (C0008U1) and farm type (C0060UG1).
```{r}
FSS_data_DE %>% group_by(C0008U1,C0060UG1,C0501) %>%
count() %>%
pivot_wider(names_from = C0060UG1, values_from = n) %>%
knitr::kable()
```
## Conclusion
This could be the final output of an overview of conventional (C0501=0) and organic (C0501=1) farms for each year and the provided farm types. As this is a fake data set, these numbers make no sense.
<!-- You can also embed plots, for example: -->
<!-- ```{r pressure, echo = FALSE} -->
<!-- plot(pressure) -->
<!-- ``` -->
<!-- In that case, don't forget to commit and push the resulting figure files, so they display on GitHub and CRAN. -->