## Worldwide Vegetable Consumption Per-Capita (1961-2017) (Part 2) => 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 the working directory ### Run Code: Worldwide vegetable Consumption per Capita ``` library(ggplot2) library(scales) library(tidyr) library(dplyr) vegetable_consumption <- read.csv("./DATA/20-vegetable-consumption-per-capita.csv") colnames(vegetable_consumption) <- c("Country","Code","Year","Vegetables") vegetable_consumption %>% filter(Country == "World") %>% ggplot() + geom_line(aes(x=Year,y=Vegetables)) + scale_y_continuous(labels=comma) + labs(title="Worldwide Vegetable Consumption Per Capita by Year", subtitle = "(1961 - 2017)", y="Kilogram/Person/Year") ``` ### Top Five Countries with hight per cap consumption ``` vegie_top <- vegetable_consumption %>% filter(Year =="2017") %>% top_n(5,Vegetables) vegie_top <- as.data.frame(vegie_top) ggplot(vegie_top) + geom_col(aes(x=reorder(Country,Vegetables),y=Vegetables)) + coord_flip() + labs(title="Top Five Countries Rata by Per Capita Consumption") ``` ### Plot Bottom Five Countries by Per Capita Consumption ``` vegie_bottom <- vegetable_consumption %>% filter(Year =="2017") %>% top_n(-5,Vegetables) vegie_bottom <- as.data.frame(vegie_bottom) ggplot(vegie_bottom) + geom_col(aes(x=reorder(Country,Vegetables),y=Vegetables)) + coord_flip() + labs(title="Bottom Five Countries Rata by Per Capita Consumption") ``` ### Plots: => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/bottom-five-countries-veggie-per-capita.png Bottom Five Countries Per capita => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/top-five-countries-veggie-per-capita.png Top Five Countries Per-capita => https://github.com/davidjayjackson/OWID-diet-vegetable-per-capita/blob/master/wroldwide-veggie-per-capita.png Worldwide Vegetables 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 ### Comments, Questions, Request: => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit/issues Comment, Questions or Request