Climate change

Climate change is one of the most fiercely debated scientific issues of the past 20 years. Human-induced warming is superimposed on a naturally varying climate, the temperature rise has not been, and will not be, uniform or smooth across the country or over time.

we will include some libraries that needed in R Markdown.

#loading certain packages 
pacman::p_load(tidyverse,ggridges,gt,alluvial, highcharter,streamgraph) 
library(dplyr)
library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library("RColorBrewer")
#setting our working directory
setwd("C:/Users/clovi/OneDrive/Desktop/DATA 110")
GHG_Data <- read.csv("Greenhouse Gas Emissions worldwide.csv",TRUE, sep = ",", stringsAsFactors = FALSE)

Climate Change - Preparing Data Data Source:

This data is chosen from https://www.kaggle.com/hafeezabro/greenhouse-gas-emissions-worldwidecsv

The Greenhouse Gas (GHG) Inventory Data contains the most recently submitted information, covering the period from 1990 to the latest available year, to the extent the data have been provided. The GHG data contain information on anthropogenic emissions by sources and removals by sinks of the following Green House Gases: Carbon dioxide (CO2), Methane (CH4), Nitrous oxide (N2O), Hydrofluorocarbons (HFCs), Perfluorocarbons (PFCs), Unspecified mix of HFCs and PFCs, Sulphur hexafluoride (SF6) and Nitrogen triflouride (NF3))

that are not controlled by the Montreal Protocol. This “Greenhouse Gas Emissions worldwide” file is a CSV file containing 989 observations with 8 columns or variables with six(6) of them being nums in decimal form, one (year) is an interger and the remaining one (Country area) are character.

We can see the strcture and dimension of the data set using the command:

str(GHG_Data)
## 'data.frame':    989 obs. of  8 variables:
##  $ Country.or.Area  : chr  "Australia" "Australia" "Australia" "Australia" ...
##  $ Year             : int  2012 2011 2010 2009 2008 2007 2006 2005 2004 2003 ...
##  $ co2_gigagrams    : num  397831 398161 399365 398669 399084 ...
##  $ hfc_gigagrams    : num  7945 7512 6943 6353 5811 ...
##  $ methane_gigagrams: num  111709 110275 109063 110807 113593 ...
##  $ pfc_gigagrams    : num  254 259 244 308 381 ...
##  $ sf6_gigagrams    : num  134 134 145 143 158 ...
##  $ n2o_gigagrams    : num  25775 25201 24452 24898 25547 ...
dim(GHG_Data)
## [1] 989   8

Fixing the problem of missing values within the Dataset It might happen that your dataset is not complete, and when information is not available we call it missing values

Lets now create a new data set without missing data

new_GHG_Data <- na.omit(GHG_Data)

Now we look at the dimension of the new data frame.

dim(new_GHG_Data)
## [1] 715   8

We observe here that the dimension of the original data frame and the new data frame are kind of thesame in form but different in depth, this is because some countries had to disappear in the new nataframe after taking out the missing variables. Example is the United States of America

Rename the different columns

Updated_new_GHG_Data <- new_GHG_Data %>% 
 rename(c( Country = Country.or.Area, CO2 = co2_gigagrams, HFC = hfc_gigagrams, CH4 = methane_gigagrams,
           PFC = pfc_gigagrams, SF6 = sf6_gigagrams, N2O = n2o_gigagrams ) ) %>% 
  arrange((Year))

Exploratory Data Anlysis (EDA) EDA aims to find patterns and relationships in data.

Making a Density Ridge Gradient

Updated_new_GHG_Data %>% 

select("Country" ,"CO2", "Year") %>% 
ggplot(aes(x = Year , y = CO2)) + 
  geom_density_ridges_gradient(aes( y = 'Country'), 
                               scale = 3, size = 0.3, alpha = 0.5) +
  scale_fill_gradientn(colours = c("#0D0887FF", "#CC4678FF", "#F0F921FF"),
                       name = "CO2") +
  labs(title = 'Russian Federation CO2 Emission') + 
  theme(legend.position = c(0.9,0.2)) +
  xlab("Year") + 
  ylab("CO2 emission")+theme_minimal(base_size = 10)
## Picking joint bandwidth of 1.52

Variations of CO2, N2O, CH4 and HCF by year

library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.0.5
#par(mfrow=c(2,2))
scat_plot1 <-  ggplot(Updated_new_GHG_Data, aes(Year, CO2))+geom_line(colour="blueviolet")+geom_smooth(method = "lm")+ggtitle("Carbon Dioxide")
scat_plot2<-  ggplot(Updated_new_GHG_Data, aes(Year, HFC))+geom_line()+geom_smooth(method = "lm")+ggtitle("Hydrofluorocarbons")
scat_plot3<-  ggplot(Updated_new_GHG_Data, aes(Year, CH4))+geom_line(colour="springgreen4")+geom_smooth(method = "lm")+ggtitle("Methane")
scat_plot4 <-  ggplot(Updated_new_GHG_Data, aes(Year, N2O))+geom_line(colour="mediumorchid4")+ggtitle("Nitrous oxide")
grapgh_arrange<-ggarrange(scat_plot1, scat_plot2, scat_plot3, scat_plot4 + rremove("x.text"), 
          labels = c("A", "B", "C", "D"),
          ncol = 2, nrow = 2)
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
annotate_figure(grapgh_arrange,
                top = text_grob("Vartations of CO_2, N2O, CH4 and HFC by year", color = "red", face = "bold", size = 14)
)

# prepare data
big5 <- GHG_Data %>%
  filter(Country.or.Area == "Russian Federation" | Country.or.Area == "United States of America" | Country.or.Area == "United Kingdom" | Country.or.Area == "France" | Country.or.Area== "  
Canada") %>% 
  arrange(Year) 
big5 %>% 
  group_by(Country.or.Area, Year) %>% 
  ggplot(aes(x = Year, y = co2_gigagrams, col = Country.or.Area)) + 
  geom_point(alpha = 0.5) +
  geom_smooth(se = F, span = 0.2) +
  scale_x_continuous(breaks = seq(1990, 2012, 5), minor_breaks = F) +
  labs(tiltle = "United Kingdom, France, United States of America, Russian Federation, and Canada",
       subtitle = "Five Big CO2 pollutants, from 1990 to 2012",
       x = "Year",
       y = "CO2 Emission (in gigagrams)",
       col = "Country.or.Area")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning in sqrt(sum.squares/one.delta): NaNs produced

## Warning in sqrt(sum.squares/one.delta): NaNs produced

## Warning in sqrt(sum.squares/one.delta): NaNs produced

## Warning in sqrt(sum.squares/one.delta): NaNs produced

# basic symbol-and-line chart, default settings
highchart() %>%
  hc_add_series(data = big5,
                   type = "line", hcaes(x = Year,
                   y = co2_gigagrams, 
                   group = Country.or.Area))
# customize the tooltips

big5_chart <- highchart() %>%
  hc_add_series(data = big5,
                   type = "line",
                   hcaes(x = Year,
                   y = co2_gigagrams, 
                   group = Country.or.Area)) %>%
  
  hc_xAxis(title = list(text="Year")) %>%
  hc_yAxis(title = list(text="CO2 Emission (in gigagrams)")) %>%
  hc_plotOptions(series = list(marker = list(symbol = "circle"))) %>%
  hc_legend(align = "right", 
            verticalAlign = "top") %>%
  hc_tooltip(shared = TRUE,
             borderColor = "green",
             pointFormat = "{point.Country.or.Area}: {point.co2_gigagrams:.2f}<br>")
big5_chart

The Greenhouse Gas (GHG) Inventory Data contains the most recently submitted information, covering the period from 1990 to the latest available year, to the extent the data have been provided. The GHG data contain information on anthropogenic emissions by sources and removals by sinks of the following Green House Gases: Carbon dioxide (CO2), Methane (CH4), Nitrous oxide (N2O), Hydrofluorocarbons (HFCs), Perfluorocarbons (PFCs), Unspecified mix of HFCs and PFCs,Sulphur hexafluoride (SF6) and Nitrogen triflouride (NF3)),that are not controlled by the Montreal Protocol. This “Greenhouse Gas Emissions worldwide” file is a CSV file containing 989 observations with 8 columns or variables with six(6) of them being nums in decimal form, one (year) is an integer and the remaining one (Country area) are character. This dataset is gotten from kaggle (https://www.kaggle.com/hafeezabro/greenhouse-gas-emissions-worldwidecsv) and was initially named “Greenhouse gas emission worldwide”, was then renamed as GHG_ data, filled with NA’s. So we had to clean the GHG data by omiting all the NA, which inturn eliminated some of the countries in question. Not only was the NA’s filtered, we also had to rename most of the variables to give a better name for easy comprehension. Global climate change has already had observable effects on the environment. Glaciers have shrunk, ice on rivers and lakes is breaking up earlier, plant and animal ranges have shifted and trees are flowering sooner. Effects that scientists had predicted in the past would result from global climate change are now occurring: loss of sea ice, accelerated sea level rise and longer, more intense heat waves. Climate change is particulary important to me because I have felt it first hand coming from a continent where the impacts are far reaching. Some of the long-term effects of global climate change in the United States are such that change will continue through this century and beyond, as temperatures will continue to rise, frost-free season (and growing season) will lengthen, more changes in precipitation patterns and more droughts and heat waves, hurricanes will become stronger and more intense as the sea level will rise 1-8 feet by 2100. LOoking at our visualizations, we notice that the United States which is open enough to provide data on its greenhouse gas emission leads the chart, unlike other first world countries who don’t such as China. They are no surprises to any of the information the visualizations were able to show us, given the fact that the United which has the largest economy in the world will will be the number one emitter of greenhouse gasses. The one issue we regret about this dataset is the fact that it didn’t have the GDP’s of the different countries and regions for us to do a proper analyses, and moreover, the dataset dated right back to 2012 which by all standards is considered old.

Bibliography

Effects | Facts – Climate Change: Vital Signs of the Planet(https://climate.nasa.gov/effects.amp)

Biktash, Lilia. 2017. “Long-Term Global Temperature Variations Under Total Solar Irradiance, Cosmic Rays, and Volcanic Activity.” Journal of Advanced Research 8 (4): 329–32. https://doi.org/https://doi.org/10.1016/j.jare.2017.03.002.

Change, Climate. 2001. “Climate Change.” Synthesis Report.

Huang, Yan, Robert E Dickinson, and William L Chameides. 2006. “Impact of Aerosol Indirect Effect on Surface Temperature over East Asia.” Proceedings of the National Academy of Sciences 103 (12): 4371–6.

Ohring, George. 1979. “The Effect of Aerosols on the Temperatures of a Zonal Average Climate Model.” Pure and Applied Geophysics 117 (5): 851–64.

Paudel, Shukra Raj, Ohkyung Choi, Samir Kumar Khanal, Kartik Chandran, Sungpyo Kim, and Jae Woo Lee. 2015. “Effects of Temperature on Nitrous Oxide (N2o) Emission from Intensive Aquaculture System.” Science of the Total Environment 518: 16–23.

Rossiter, D G. 2008. “Tutorial: An Example of Statistical Data Analysis Using the R Environment for Statistical Computing.”