co2_percap <- read_csv("C:/Users/jason/OneDrive/SAIT/SAIT Instructor/2025-2026/SPRING 2025 - COURSE - DATA420/data/per-capita-co-emissions.csv")
co2_percap <- co2_percap %>%
rename(Country = Entity)
p <- co2_percap %>%
ggplot(aes(Year, `Annual CO2 emissions (per capita)`, color = Country)) +
geom_line(linewidth=0.5) +
scale_y_continuous(labels = function(x) paste0(x, " t")) +
labs(title = "Annual CO2 Emissions Per Capita by Country",
x = "Year",
y = "CO2 Emissions (per capita)",
color = "Country") +
theme_minimal()
ggplotly(p)co2_industry <- read_csv("C:/Users/jason/OneDrive/SAIT/SAIT Instructor/2025-2026/SPRING 2025 - COURSE - DATA420/data/per-capita-co2-fuel.csv")
co2_industry %>%
ggplot(aes(x = reorder(Industry, CO2Emissions), y = CO2Emissions)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = round(CO2Emissions, 2)),
hjust = -0.1, color = "black", size = 3.5) +
coord_flip() +
labs(title = "CO2 Emissions by Industry (2023)",
x = "",
y = "Emissions (tonnes per capita)") +
scale_y_continuous(labels = scales::label_number(suffix = " t"),
expand = expansion(mult = c(0, 0.1))) +
theme_minimal()co2_country <- read_csv("C:/Users/jason/OneDrive/SAIT/SAIT Instructor/2025-2026/SPRING 2025 - COURSE - DATA420/data/per-capita-co2-country.csv")
# Quick fix: replace country names for compatibility
co2_country_fixed <- co2_country %>%
mutate(Country = case_when(
Country == "United States" ~ "United States of America",
Country == "Democratic Republic of Congo" ~ "Democratic Republic of the Congo",
Country == "Czechia" ~ "Czech Republic",
Country == "Ivory Coast" ~ "Côte d'Ivoire",
TRUE ~ Country
))
world <- ne_countries(scale = "medium", returnclass = "sf")
# Join the CO2 data to the map
world_co2 <- world %>%
left_join(co2_country_fixed, by = c("name" = "Country"))
ggplot(world_co2) +
geom_sf(aes(fill = `Annual CO2 Emissions per Capita`), color = "gray60", size = 0.1) +
scale_fill_viridis_c(
option = "plasma",
na.value = "black",
name = "CO2 per capita\n(tonnes)",
limits = c(0, 25)
) +
labs(title = "Annual CO2 Emissions per Capita by Country (2023)",
caption = "Data Source: per-capita-co2-country.csv") +
theme_minimal()df <- read_csv("C:/Users/jason/OneDrive/SAIT/SAIT Instructor/2025-2026/SPRING 2025 - COURSE - DATA420/data/per-capita-co-transport.csv")
# Pivot and arrange factor levels so Road is at the bottom
df_long <- df %>%
pivot_longer(cols = -Year, names_to = "Transport", values_to = "Emissions") %>%
mutate(
Transport = factor(Transport, levels = c("Road", "Rail", "Shipping", "Aviation", "Pipeline transport"))
)
p3 <- df_long %>%
ggplot(aes(Year, Emissions, fill = Transport)) +
geom_area(color = "white", alpha = 0.70) +
scale_fill_brewer(palette = "Set2") +
labs(
title = "Per Capita CO2 Emissions by Transport Mode (1990–2022)",
x = "Year",
y = "Emissions (tonnes per capita)",
fill = "Transport"
) +
theme_minimal()
ggplotly(p3)