Worldwide/United States : Vegetable Consumption Per Capita (1961 - 2013) [Part 2/3]

Our World In Data

Software required to recreate plot:

US Vegetable Consumption per Capita in Kilograms

library(ggplot2)
library(scales)
library(dplyr)
library(tidyr)
rm(list=ls())

vegetable_consumption <- read.csv("./DATA/20-vegetable-consumption-per-capita.csv")
colnames(vegetable_consumption) <- c("Country","Code","Year","Vegetables")

vegetable_consumption %>% filter(Country == "United States") %>%
  ggplot() + geom_line(aes(x=Year,y=Vegetables),lwd=2,col="red") +
  scale_y_continuous(labels=comma) +
  labs(title="United States Vegetable Consumption Per Capita by Year",
       subtitle = "(1961 - 2017)",
       y="Kilogram/Person/Year")

US Veggie Consumption Per-Capita

Top Five Countries with highest per cap consumption

vegie_top <- vegetable_consumption %>% filter(Year =="2017") %>%  top_n(5,Vegetables)
vegie_top <- as.data.frame(vegie_top)
countries_top_five <- vegie_top %>% select(Country) %>% left_join(vegetable_consumption,by="Country")
head(countries_top_five)
tail(countries_top_five)

ggplot(countries_top_five) + geom_line(aes(x=Year,y=Vegetables,col=Country)) +
  labs(title = "Vegetables Consumption Kg/Person/Year",subtitle = "( Top 5 countries)",
       y="Vegetables Consumed per person Kg")
	   
ggplot(countries_top_five) + geom_col(aes(x=Year,y=Vegetables)) +
  facet_wrap(~Country) + labs(title="Top Five Countries by Per Capita ",
                              subtitle = "(Vegetable Consumption per Capita)",
                              y="Vegetables by Kg/Person/Year")
	   

Top 5 Broken out by Country

Top 5 Countries by Per Capita

Resources:

R Code, and data

R Language and Rtools40 (click and "base" and "Rtools")

Download and install RStudio

Comments, Question and Request