---
title: "R Notebook"
output: html_notebook
---

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*. 

```{r}
library(tidyverse)
```


```{r}
df <- data.frame(F = seq(1:100))

fun.1 <- function(F, a = 0.11) {F * a}
fun.2 <- function(F, a = 1, b = 0.1) { F * a / (1 + b * F)}
fun.3 <- function(F, a = 1, b = 0.05) {a * F * exp(-b * F)}

p1 <- ggplot(data = df, mapping = aes(x = F)) + stat_function(fun = fun.1) + xlim(0, 100) + 
  ggtitle("Linear") + xlab("N [kg/ha]") + ylab("Yield [kg/ha]") + ylim(1,10)

p2 <- ggplot(data = df, mapping = aes(x = F)) + stat_function(fun = fun.2) + xlim(0, 100) + 
  ggtitle("Saturation") + xlab("N [kg/ha]") + ylab("") + ylim(1,10)

p3 <- ggplot(data = df, mapping = aes(x = F)) + stat_function(fun = fun.3) + xlim(0, 100) + 
  ggtitle("Optimum") + xlab("N [kg/ha]") + ylab("") + ylim(1,10)

arr <- ggarrange(p1, p2, p3, labels = c("A", "B", "C"), ncol = 3, nrow = 1)

arr

ggsave("yield-models.pdf")
```


