-- Leo's gemini proxy
-- Connecting to gemlog.blue:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
Countries shown in blue have an average per capita intake below 250g per person per day; countries in green are greater than 250g. National and World Health Organization (WHO) recommendations tend to range between 200-250g per day.
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
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") veggie_average <- vegetable_consumption %>% group_by(Year) %>% summarise(Average = mean(Vegetables), Median = median(median(Vegetables)), Maximum = max(Vegetables))
veggie_average <- as.data.frame(veggie_average) ggplot(veggie_average) + geom_line(aes(x=Year,y=Average,col="Average")) + geom_line(aes(x=Year,y=Median,col="Median")) + geom_line(aes(x=Year,y=Maximum,col="Maximum")) + scale_y_log10() + labs(title="Vegetable Consumtion Per Capita(Plot One)", y="Mean/Median/Maximum")
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 (Plot Two)",subtitle = "(Bottom 5 countries)", y="Vegetables Consumed per person Kg")
ggplot(countries_top_five) + geom_col(aes(x=Year,y=Vegetables)) + facet_wrap(~Country,ncol=2,scale="free_y") + labs(title="Bottom Five Countries by Per Capita (Plot 3) ", subtitle = "(Vegetable Consumption per Capita)", y="Vegetables by Kg/Person/Year") + geom_line(data=veggie_average,aes(x=Year,y=Average,col="Mean"))
-- Response ended
-- Page fetched on Fri Apr 26 19:58:55 2024