Libraries
Data import
Using the tidytuesdayR
package this task is easy:
data <- tidytuesdayR::tt_load(2021, week = 5)
--- Compiling #TidyTuesday Information for 2021-01-26 ----
--- There is 1 file available ---
--- Starting Download ---
Downloading file 1 of 1: `plastics.csv`
--- Download complete ---
plastics <- data$plastics
Total plastic counts per country
plastics_country <- plastics |>
mutate(country = case_when(
country == "ECUADOR" ~ "Ecuador",
country == "NIGERIA" ~ "Nigeria",
country == "United Kingdom of Great Britain & Northern Ireland" ~ "Ireland",
TRUE ~ country
)) |>
group_by(country) |>
summarise(
total = sum(grand_total)
) |>
arrange(desc(total)) |>
mutate(abbreviation = countrycode(country, "country.name", "cldr.name.en")) |>
mutate(flags = countrycode(country, "country.name", "unicode.symbol")) |>
filter(!country == "EMPTY") |>
mutate(total = ifelse(is.na(total), 0, total))
plastics_country |>
ggplot(aes(total, reorder(abbreviation, -total))) +
geom_col() +
geom_text(aes(label = total), size = 3, color = "black", hjust = -0.7) +
labs(
x = "Total plastic counts [n]",
y = ""
) +
theme_minimal() +
scale_x_continuous(guide = "prism_offset_minor", limits = c(0, 270000)) +
coord_cartesian(expand = FALSE)
Citation
BibTeX citation:
@online{garcía-botero2020,
author = {García-Botero, Camilo},
title = {Plastic Pollution in Countries},
date = {2020-10-26},
langid = {en}
}
For attribution, please cite this work as:
García-Botero, Camilo. 2020. “Plastic Pollution in
Countries.” October 26, 2020.