## Worldwide/United States : Vegetable Consumption Per Capita (1961 - 2013) [Part 2/3] => http://ourworldindata.org Our World In Data ### Software required to recreate plot: * Install: R language, RTools40 and RStudio (see link below) * Packages: GGPLot2, dplyr, janitor. * Download code and data from Github.com (see link below). * Move R code and data to working directory ### 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") ``` => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/us_veggie_per_capita.png 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") ``` => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/top-5-countries-by-per-capita.png Top 5 Broken out by Country => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/top_five_countries_per_capita.png Top 5 Countries by Per Capita ## Resources: => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit R Code, and data => https://cloud.r-project.org/ R Language and Rtools40 (click and "base" and "Rtools") => https://rstudio.com/products/rstudio/download/ Download and install RStudio => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit/issues Comments, Question and Request