knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(cwdata)
library(tidyverse)
key_crop_yields %>% 
  filter(year == 2017) %>% 
  group_by(crop) %>% 
  summarise(tonnes_per_hectare = sum(tonnes_per_hectare, na.rm = TRUE)) %>% 
  ggplot(aes(fct_reorder(crop,tonnes_per_hectare, .desc = TRUE),
             y = tonnes_per_hectare))+
  geom_col()+
  labs(x = "Crop",
       y = "Tonnes per hectare",
       title = "Global crop production")

The most produced crop in the world is potatoes!

key_crop_yields %>% 
  group_by(year,crop) %>% 
  summarise(tonnes_per_hectare = sum(tonnes_per_hectare, na.rm = TRUE)) %>% 
  ggplot(aes(x = year,
             y = tonnes_per_hectare,
             color = crop))+
  geom_line()+
  theme_bw()+
  labs(y = "Tonnes per hectare",
       x = "Crop",
       title = "Global crop production")


Erin317/cwdata documentation built on Dec. 17, 2021, 7:23 p.m.