# Fruit Consumption Per Capita: 1960 - 2017 ## Five Countries with highest Fruit Consumption ### Source: Our World In Data => HTTP://ourworldindata.org ### 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 => https://youtu.be/LPlFnHRV2Hs Walkthough (R Code) => https://git.skyjake.fi/skyjake/lagrange/releases Gemini Browser => gemini://gemlog.blue/users/cariboudatascience/ Caribou Data Science(Capsule) ## Run R Code: ``` library(ggplot2) library(scales) library(dplyr) library(tidyr) ## Import Fruit Consumption data rm(list=ls()) fruit <- read.csv("./DATA/1-fruit-consumption-per-capita.csv") fruit <- fruit %>%select(-Code) colnames(fruit) <- c("Country","Year","Fruits") fruits_top <- fruit %>% filter(Year =="2017") %>% top_n(5,Fruits) fruits_top <- as.data.frame(fruits_top) ggplot(fruits_top) + geom_col(aes(x=reorder(Country,Fruits),y=Fruits)) + coord_flip() + labs(title="Top 5 countries by per Capita Fruit Production") countries_five <- fruits_top %>% select(Country) %>% left_join(fruit,by="Country") head(countries_five) tail(countries_five) ### Plot Top % Countries by Kg cosummed per year per person. ggplot(countries_five) + geom_line(aes(x=Year,y=Fruits,col=Country)) + labs(title = "Fruit Consumption Kg/Person/Year",subtitle = "( Top 5 countries)", y="Fruit Consumed per person Kg") ### Plot of US Fruit consumption fruit %>% filter(Country =="United States") %>% ggplot() + geom_line(aes(x=Year,y=Fruits)) + labs(title="US Fruit Consumption: Kg/Year/Person (1960-2017)", y="Kilograms Per Person") ``` ### Plots: => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit/blob/main/Top_five_cointries.png Top 5 Countries => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit/blob/main/top_five_countries.png Top 5 Countries by Year => https://github.com/davidjayjackson/OWID-diet-vegetable-fruit/blob/main/us_fruit_per_person.png US Fruit Comsumption by Year ## 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