Proof of climate change

Column

Global Land temperature in degrees Celsius

Land Average temperature by year

CO2 trend and high-low temperatures

Column

CO2 trend

Column

High-low average temperature trend

Energy Demand in USA

Column

Annual Residential Energy Demand

Ecological Footprint

Column

Northern Hemishpere Sea Ice Extent

---
title: "Climate data analysis"
author: "Mrugank Salunke"
date: "07/09/2020"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
---
```{r setup, include=FALSE}
setwd('C:/Users//mruga/Desktop/')
library(ggplot2)
library(grid)
library(gridExtra)
library(RColorBrewer)
library(ggthemes)
library(dplyr)
library(sp)
library(rworldmap)
library(data.table)
library(Amelia)
library(caret)
library(ggfortify)
library(forecast)
library(imputeTS)





options(width=100)
knitr::opts_chunk$set(out.width='1000px',dpi=200,message=FALSE,warning=FALSE)

```

Proof of climate change {data-orientation=columns}
==========================================================================

Sidebar {.sidebar}
-----------------------------------------------------------------------
### Earth's surface temperature rise

This vizualization tries to debunk the fact that global climate change is not real. There is enough proof out there that tells us that temperaure rise is infact a reality.

In the following Graphs you see that temperature rise has been recorded over 100+ years and there is a gradual increase in average temperature. We can say that there is nearly a 2 deg increase in tempereature since 1900.


Source: (https://www.kaggle.com/berkeleyearth/climate-change-earth-surface-temperature-data)

Column {.tabset .tabset-fade data-height=500}
-----------------------------------------------------------------------
  
### Global Land temperature in degrees Celsius
```{r}
global<-read.csv('GlobalTemperatures.csv')
global$date<-as.Date(global$dt)
global$year<-as.numeric(format(global$date,'%Y'))
global %>% 
  filter(year>=1900) %>% 
  dplyr::select(LandAverageTemperature, LandAverageTemperatureUncertainty, year) %>% 
  group_by(year) %>% 
  summarise(avgTemp = mean(LandAverageTemperature), avgError = mean(LandAverageTemperatureUncertainty)) %>% 
  ggplot(aes(x=year,y = avgTemp)) + 
  geom_point(aes(size=avgError,color=avgTemp),alpha=.75) + 
  theme(legend.position='top') + 
  theme_fivethirtyeight() + ylim(5,12) + 
  ggtitle('Global Land temperature in degrees Celsius') + 
  geom_smooth(color='black',size=.4)
```

###  Land Average temperature by year

```{r}
glo = fread("GlobalTemperatures.csv")
glo[,dt:=as.Date(glo[,dt])]
glo[,year:=year(glo[,dt])]
glo[,month:=month(glo[,dt])]
glo[,season:=ifelse(month %in% c(6,7,8),"Summer",
                    ifelse(month %in% c(9,10,11),"Fall",
                           ifelse(month %in% c(12,1,2),"Winter","Spring")
                    ))]
ggplot(data = glo, 
    aes(dt,LandAverageTemperature, colour=season)) +
        geom_point(na.rm = T) +
        xlab("Year") +
        ggtitle("Land Average temperature by year")

```


CO2 trend and high-low temperatures {data-orientation=columns}
==========================================================================

Sidebar {.sidebar}
-----------------------------------------------------------------------
### CO2 rise in the atmosphere and subsequent temperature rise

CO2 is one of the major greenhouse gases that cause the rise in temperature. An increase in CO2 is a good measure of indication that the temperatures to rise. As you can see, at globaly in 1960 we had 300 ppm of CO2 and currently we have crossed 400 ppm

Data source: https://www.kaggle.com/ucsandiego/carbon-dioxide


Column {data-width=400}
------------------------------------------------------------------------------
  
###  CO2 trend
  
```{r}
co<-read.csv('archive.csv',sep=',')
colnames(co)<-c('year','month','decimal_date','carbon_dioxide_ppm','carbon_dioxide_ppm_season_adj','carbon_dioxide_ppm_fit','carbon_dioxide_ppm_season_adj_fit')

ggplot() + 
  geom_line(data=co,aes(x=decimal_date,y=carbon_dioxide_ppm,color="carbon_dioxide"),alpha=.70) +
  geom_line(data=co,aes(x=decimal_date,y=carbon_dioxide_ppm_season_adj,color="carbon_dioxide_adjusted"),alpha=.70) +
  theme(legend.position="top") +
  xlab('') + ylab('concentrations [ppm]')
```

Column {data-width=400}
------------------------------------------------------------------------------
  
### High-low average temperature trend
```{r}
GT = fread("GlobalTemperatures.csv")
GT[,dt:=as.Date(GT[,dt])]
GT[,year:=year(GT[,dt])]
GT[,month:=month(GT[,dt])]
GT[,season:=ifelse(month %in% c(6,7,8),"Summer",
                    ifelse(month %in% c(9,10,11),"Fall",
                           ifelse(month %in% c(12,1,2),"Winter","Spring")
                    ))]
# Average Max
High.GT = aggregate(GT$LandMaxTemperature, 
                by=list(GT$year), 
                FUN=mean)
# Average Min
Low.GT = aggregate(GT$LandMinTemperature, 
                  by=list(GT$year), 
                  FUN=mean)

HighLow.GT = data.table(merge(Low.GT, High.GT, by = "Group.1"))
names(HighLow.GT) <- c("year","Low","High")
MeltedHighLow.GT = melt(HighLow.GT,
                        id = "year",
                        na.rm = T,
                        variable.name = "Temperature")

ggplot(data = MeltedHighLow.GT,
       aes(year, value)) +
        geom_line(na.rm = T) +
        facet_grid(Temperature ~ ., scales = "free_y") +
        xlab("Year") +
        geom_smooth() +
        geom_vline(xintercept = 1900, alpha = 0.5) +
        geom_vline(xintercept = 1975, alpha = 0.5) +
        ggtitle("High and Low average Temperature trend")
```



Energy Demand in USA {data-orientation=columns}
==========================================================================

Sidebar {.sidebar}
-----------------------------------------------------------------------

### Energy Demand

The visualization shown here enumerates the worst affected cities in the world in terms of temperature. In addition to the temperature rise consequences, flooding is another major disastrous consequence. This is not shown in the visualization, however, some of the smaller islands around the world are already going under the sea, causing major population migration to the central parts of the land and in turn causing overcrowding.  



Column {data-width=800}
-----------------------------------------------------------------------
  
### Annual Residential Energy Demand 
  
```{r}

REDTI_data = read.csv(url("https://www.ncdc.noaa.gov/societal-impacts/redti/USA/jun/1-month/data.csv"),skip=1)


ggplot(REDTI_data,aes(x=Date,y=REDTI)) +
  geom_area(color = "black" ,fill = "gray")+ 
  scale_y_continuous(limits = c(0, 100))+
  geom_smooth(method='lm',se=FALSE)+
  labs(title="Annual Residential Energy Demand Temperature Index [REDTI]",x="Year",y="REDTI")
```

Ecological Footprint {data-orientation=columns}
==========================================================================

Sidebar {.sidebar}
-----------------------------------------------------------------------
### Sea Ice Extent

This vizualization depicts the lowering ics extent in the northern hemisphere. Melting ice has a direct coorelation to increasing temperature.



Column 
-----------------------------------------------------------------------
  
### Northern Hemishpere Sea Ice Extent

```{r}
NHSI <- read.csv(url("https://www.ncdc.noaa.gov/snow-and-ice/extent/sea-ice/N/8.csv"),skip=3)

ggplot(NHSI,aes(x=Date,y=Value))+
  geom_point(color = "blue")+
  geom_smooth(method = 'lm', color = "red")+
  labs(title="Northern Hemisphere Sea Ice Extent (1979-2019)",x="Year",y="million square km")

```