Code
library(tidyverse)
library(ggplot2)
library(here)
::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE) knitr
Daniel Manning
January 28, 2023
# A tibble: 38,170 × 14
`Domain Code` Domain `Area Code` Area `Element Code` Element `Item Code`
<chr> <chr> <dbl> <chr> <dbl> <chr> <dbl>
1 QL Livestock… 2 Afgh… 5313 Laying 1062
2 QL Livestock… 2 Afgh… 5410 Yield 1062
3 QL Livestock… 2 Afgh… 5510 Produc… 1062
4 QL Livestock… 2 Afgh… 5313 Laying 1062
5 QL Livestock… 2 Afgh… 5410 Yield 1062
6 QL Livestock… 2 Afgh… 5510 Produc… 1062
7 QL Livestock… 2 Afgh… 5313 Laying 1062
8 QL Livestock… 2 Afgh… 5410 Yield 1062
9 QL Livestock… 2 Afgh… 5510 Produc… 1062
10 QL Livestock… 2 Afgh… 5313 Laying 1062
# … with 38,160 more rows, and 7 more variables: Item <chr>, `Year Code` <dbl>,
# Year <dbl>, Unit <chr>, Value <dbl>, Flag <chr>, `Flag Description` <chr>
---
title: "Challenge 9"
author: "Daniel Manning"
description: "Creating a function"
date: "1/28/2023"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge_9
---
```{r}
#| label: setup
#| warning: false
#| message: false
library(tidyverse)
library(ggplot2)
library(here)
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```
## Create a function
```{r}
plot_hist <-function(d, x){
ggplot(d, aes(x=x)) + geom_histogram() +
geom_histogram(binwidth=1000)
}
```
## Load Dataset
```{r}
egg <- here("posts","_data","FAOSTAT_egg_chicken.csv")%>%
read_csv()
egg
```
## Test function
```{r}
plot_hist(egg, egg$Value)
```