USA Cereals Consumption By Type (Kilocalories/person/year) [Part 4]

Begin Code

library(ggplot2)
library(scales)
library(dplyr)
library(tidyr)
library(readr)
library(flextable)
library(dlookr)
rm(list=ls())

cereals <- read.csv("./DATA/per-capita-consumption-of-cereals-by-commodity-type-daily-kilocalories.csv") 
colnames(cereals) <- c("Country","Code","Year","Wheat","Rice","Barley","Maize","Rye","Oats","Sorghum")
us_cereals <- cereals %>% filter(Code == "USA") 
us_longer <- us_cereals %>% pivot_longer(cols = Wheat:Sorghum,names_to ="Cereals",values_to ="Calories" )

Table of Summary Statistics

us_cereals %>% select(-Country,-Code, -Year) %>% dlookr::diagnose_numeric() %>% flextable()

Summary Table 1

us_longer %>% select(-Country,-Code,-Year) %>% dlookr::diagnose_category() %>% flextable()

Summary Table 2

Plot of US Cereal Consumption by Kilocalories by Cereals

ggplot(us_longer) + geom_line(aes(x=Year,y=Calories,col=Cereals),lwd=1) +
  labs(title = "US Cereals Consumption By Cereals",y="Kilocalories") +
  facet_wrap(~Cereals,scales="free_y")

Summary by Cerael Type

Resource:

R Code and data.