Code
library(tidyverse)
::opts_chunk$set(echo = TRUE) knitr
Neha Jhurani
May 12, 2023
Rows: 38170 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
[1] 38170 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
Rows: 82116 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
[1] 82116 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
Rows: 36449 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): Domain Code, Domain, Area, Element, Item, Unit, Flag, Flag Description
dbl (6): Area Code, Element Code, Item Code, Year Code, Year, Value
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
[1] 36449 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
Joining with `by = join_by(`Domain Code`, Domain, `Area Code`, Area, `Element
Code`, Element, `Item Code`, Item, `Year Code`, Year, Unit, Value, Flag, `Flag
Description`)`
[1] 118565 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
Joining with `by = join_by(`Domain Code`, Domain, `Area Code`, Area, `Element
Code`, Element, `Item Code`, Item, `Year Code`, Year, Unit, Value, Flag, `Flag
Description`)`
[1] 74619 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
Joining with `by = join_by(`Domain Code`, Domain, `Area Code`, Area, `Element
Code`, Element, `Item Code`, Item, `Year Code`, Year, Unit, Value, Flag, `Flag
Description`)`
[1] 120286 14
[1] "Domain Code" "Domain" "Area Code" "Area"
[5] "Element Code" "Element" "Item Code" "Item"
[9] "Year Code" "Year" "Unit" "Value"
[13] "Flag" "Flag Description"
---
title: "Joining datasets"
author: "Neha Jhurani"
desription: "datasets: FAOSTAT_egg_chicken.csv, FAOSTAT_livestock.csv, FAOSTAT_cattle_dairy.csv"
date: "05/12/2023"
format:
html:
toc: true
code-fold: true
code-copy: true
code-tools: true
categories:
- challenge8
- Neha Jhurani
- FAOSTAT_egg_chicken.csv, FAOSTAT_livestock.csv, FAOSTAT_cattle_dairy.csv
---
```{r}
#| label: setup
#| warning: false
library(tidyverse)
knitr::opts_chunk$set(echo = TRUE)
```
## Eggs / Livestock / Dairy data
```{r}
library(readr)
#reading FAOSTAT_egg_chicken csv data
eggs_data <- read_csv("_data/FAOSTAT_egg_chicken.csv")
dim(eggs_data)
#extracting column names of eggs data
colnames(eggs_data)
#reading FAOSTAT_livestock csv data
livestock_data <- read_csv("_data/FAOSTAT_livestock.csv")
dim(livestock_data)
#extracting column names of livestock data
colnames(livestock_data)
#reading FAOSTAT_cattle_diary csv data
dairy_data <- read_csv("_data/FAOSTAT_cattle_dairy.csv")
dim(dairy_data)
#extracting column names of dairy data
colnames(dairy_data)
#Joining Data
#Joining dairy and livestock data
dairy_livestock_data <- full_join(dairy_data, livestock_data)
dim(dairy_livestock_data)
#extracting column names of combined data
colnames(dairy_livestock_data)
#Joining dairy and eggs data
dairy_eggs_data <- full_join(dairy_data, eggs_data)
dim(dairy_eggs_data)
#extracting column names of combined data
colnames(dairy_eggs_data)
#Joining livestock and eggs data
livestock_eggs_data <- full_join(livestock_data, eggs_data)
dim(livestock_eggs_data)
#extracting column names of combined data
colnames(livestock_eggs_data)
```