Carbon Dioxide Emissions

Author

Jeffrey Ren

Introduction

The data set topic I chose was carbon dioxide emissions and I got it from Zenodo. This data set includes all the countries and their sources of CO2 emissions (in million metric tons) from 1750 to 2021 although most of them are NA until 1950 at the earliest. The categorical variables are the countries and their codes. The emissions are quantitative variables and they include the total, coal, oil, gas, cement, flaring, and other that the country emitted that year. I plan to choose a specific country from the data set and explore their their sources of emissions over time too see which sources that country relies on and how it changes over time.

#loaded in the necessary libraries

library (tidyverse)
library (dplyr)
library (ggplot2)
library (ggfortify)

#loaded in and read the data set

setwd("/Users/jeffreyren/Downloads/Directory")
emissions <- read_csv("emissions.csv")

#filtered the data to only show the U.S. emissions after 1950

US <- emissions %>%
  filter(Country %in% c("USA")) %>%
  filter(Year >= 1950)

#Analyzed the linear regression and diagnostic plots

USlm <- lm (Total~Coal+Oil+Gas+Cement+Flaring, data=US)
summary(USlm)

Call:
lm(formula = Total ~ Coal + Oil + Gas + Cement + Flaring, data = US)

Residuals:
    Min      1Q  Median      3Q     Max 
-5.4549 -1.5453 -0.0327  1.8381  3.6113 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -17.870860   1.803405   -9.91 1.09e-14 ***
Coal          1.009788   0.001204  838.41  < 2e-16 ***
Oil           0.997884   0.002288  436.23  < 2e-16 ***
Gas           1.014377   0.002857  355.11  < 2e-16 ***
Cement        1.165213   0.087943   13.25  < 2e-16 ***
Flaring       1.150729   0.023267   49.46  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.261 on 66 degrees of freedom
Multiple R-squared:      1, Adjusted R-squared:      1 
F-statistic: 3.456e+06 on 5 and 66 DF,  p-value: < 2.2e-16
autoplot(USlm, 1:4, nrow=2, ncol=2)

#Created a scatterplot using ggplot that shows all 5 different variables with different colors of emission types in the United States from 1950 to 2021. Include relevant title, axes, and caption for the source. Decided on colors that would match the variables and included a legend for those variables.

invisible({
scatterplot <- ggplot(US, aes(x = Year)) +
  geom_point(aes(y = Coal, color = "Coal")) +
  geom_point(aes(y = Oil, color = "Oil")) +
  geom_point(aes(y = Gas, color = "Gas")) +
  geom_point(aes(y = Cement, color = "Cement")) +
  geom_point(aes(y = Flaring, color = "Flaring")) +
  labs(title = "Breakdown of CO2 Emissions in the United States (1950-2021)",
       x = "Years",
       y = "CO2 Emissions (in million metric tons)",
       color = "Source of Emission", 
       caption = "Source: Zenodo") +  
  scale_color_manual(values = c("Coal" = "black", "Oil" = "orange", "Gas" = "green", "Cement" = "brown", "Flaring" = "yellow"),
                     labels = c("Cement", "Coal", "Flaring", "Gas", "Oil"))
theme_classic()
})
scatterplot

Conclusion

I cleaned up the data set by filtering out all the countries except the United States. Then I filtered out the years less than or equal to 1950 because that’s when the data set has data for all emission types. The data visualization represents a break down of the sources of CO2 emissions (in million metric tons) from the U.S. and how it changes over time. The graph shows the three biggest sources of CO2 emissions by far are from oil, coal, and gas. What’s interesting is that around 2010 the U.S. has had a significant drop in CO2 emissions from coal. The rate it has decreased is steeper than when it was increasing so much so that surprisingly the lowest point for coal CO2 emissions in this time frame was around 2020. I thought for sure every emission would be higher than it was 70 years ago but that is not the case for coal. Something I wish I could show was the impact of the industrial revolution on the types of emissions but unfortunately the data set does not go that far back.