-- Leo's gemini proxy
-- Connecting to gemlog.blue:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
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(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")
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")
-- Response ended
-- Page fetched on Fri Apr 26 04:10:55 2024