Column

Temperature levels by US States

Temperatures in the US since 1850

Column

Comparing Snow Ice level in North and South Hemispher

---
title: "Climate Change Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    theme: cerulean
    source_code: embed
    
---

```{r setup, include=FALSE}
library(flexdashboard)
```

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

### **Overview**
This Dashboard looks at global temperatures and it's effects on sea ice level.
It also delves into the average temperatures by US states from 1850-2013.

### **Summary**
Global warming and climate change is real, as the world population grows along with industrialization, and carbon emission increases, it continued to cause a toll on the ozone layer which then cause world temperatures to continue to rise.



Column {data-width=450}
-----------------------------------------------------------------------

###  Temperature levels by US States
  

```{r}

library(dplyr)
library(tidyr)
library(ggplot2)
library(readxl)
cData = read_excel("C:/Users/Bonos/Downloads/GlobalLandTemperaturesByState.xlsx")
##Then I choose the United States, remove Hawaii and Alaska, and I separate the date into Year, Month and Day.

cData %>%
  filter(Country=="United States")  %>%
  separate(col = dt, into = c("Year", "Month", "Day"), convert = TRUE) ->cData
cData<-na.omit(cData)

cData %>%
  filter(State!="Hawaii" & State!="Alaska") -> cData1
# Remove na's
cData1 = na.omit(cData1)


cData1 %>% 
  filter(Year>1850) %>%
  group_by(Year) %>% 
  summarise(Temp = mean(AverageTemperature)) ->cData2

qplot(Year, Temp, data=cData2, main="US Average Temperature 1850-2013",geom=c("point","smooth"))+ aes(colour = Temp) + scale_color_gradient(low="blue", high="red")
```

### Temperatures in the US since 1850

```{r}
# Changing Georgia (State)
cData$State <- as.character(cData$State)
cData$State[cData$State=="Georgia (State)"] <- "Georgia"
cData$State<- as.factor(cData$State)                    

#' select columns of interest
cData %>% 
  select(Year,AverageTemperature,State) %>%
  group_by(Year,State) %>%
  summarise(value=mean(AverageTemperature))-> cData4

#Data frame must have a column named region (all lower case) and another one value.
colnames(cData4)[2]<- "region"
cData4$region<-tolower(cData4$region)

cData4 %>%
  filter(Year==1850) -> cData1850
cData1850<-cData1850[,2:3]

cData4 %>%
  filter(Year==2013) -> cData2013
cData2013<-cData2013[,2:3]

#Loading Packages
library(choroplethr)
library(choroplethrMaps)

print(state_choropleth(cData1850,
                       title="Land Temperature in the US", 
                       num_colors = 8,
                       legend="Degrees"),reference_map=TRUE)




```

Column {data-width=350}
---------------------------------------------------------------------

### Comparing Snow Ice level in North and South Hemispher

```{r}

library(ggthemes)
library(ggplot2)
#remove.packages("ggthemes")
north_data <- read.csv(url("https://www.ncdc.noaa.gov/snow-and-ice/extent/sea-ice/N/8.csv"),skip=4)
south_data = read.csv(url("https://www.ncdc.noaa.gov/snow-and-ice/extent/sea-ice/S/8.csv"),skip=4)

north_data$'North Sea Ice Level' = north_data$Anomaly
south_data$'South Sea Ice Level' = south_data$Anomaly

poles_data = merge(north_data[,-c(2,3)], south_data[,-c(2,3)], by="Date")
#head(poles_data)
poles_Melted <- reshape2::melt(poles_data, id.var='Date')
#head(poles_Melted)

ggplot(poles_Melted, aes(x=Date, y=value, col=variable)) + 
  geom_line(linetype="solid", size=2) +
  #scale_fill_discrete(name = “Poles”, labels = c(“North Sea Ice Level”, “South Sea Ice Level”)) +
  xlab("Date") +
  ylab("Change is Sea Ice Level") +
  ggtitle("Comparing Changes in Sea Ice Level") +
  theme_economist()

```