library(tidyverse) food_consumption <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-18/food_consumption.csv') food_co2 <- food_consumption %>% group_by(food_category) %>% summarise(total_co2 = sum(co2_emmission)) ## Ed code class(food_co2) food_co2 <- data.frame(food_co2) ?barplot #default par(mar = c(5.1, 4.1, 4.1, 2.1)) # bottom, left, top, and right #new par(mar = c(5.1, 12, 4.1, 2.1)) # bottom, left, top, and right (x <- barplot(sort(food_co2[,2], dec=F), horiz=T, xlim= c(0, 50000), xlab = "CO2 Emissions (Kg CO2/person/year)", main = "Which food category has the highest CO2 emimssions?")) #sort <- c(10,6,2,11,8,3,9,7,4,5,1) #sort <- c(1,5,4,7,9,3,8,11,2,6,10) axis(side=2, at=x, labels = food_co2$food_category[sort], las=2)