knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width=6.5,
  fig.height=5
)
library(cwdata)

This package provides the key_crop_yields dataset,which contains crop yields for countries over time.The yields are measured in tonnes per hectare for r length(unique(key_crop_yields$crop)) crops(r glue::glue_collapse(unique(key_crop_yields$crop),sep = ", ", last = " and ")).This data is sourced from Our World in Data and Tidy Tuesday.

It can be assessed via:

library(cwdata)
library(tibble) ## show just first 10 rows not all rows
key_crop_yields

Exploration of the data

Crop production in Australia:

library(ggplot2)
library(dplyr)
key_crop_yields%>%
  filter(country=="Australia")%>%
  ggplot(aes(x=year,y=tonnes_per_hectare))+
  geom_line()+
  facet_wrap(vars(crop),scales="free_y")+
  labs(y="Tonnes per hectare",
       x="Times in years",
       title="Australian crop production over time")+
  theme_bw()


yliu0320/cwdata documentation built on Oct. 17, 2020, 1:50 a.m.