💾 Archived View for gemlog.blue › users › cariboudatascience › 1616114606.gmi captured on 2024-03-21 at 17:13:45. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-04)

-=-=-=-=-=-=-

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.