Introduction - Climate Changes

Climate change and science has been an issue for discussion and debate for at least the last decade. Climate data collection is currently being collected for areas all over the world. Policy decisions are based on the most recent analysis conducted on data extracted from huge online repositories of this data. Due to the inherent growth in the electronic production and storage of information, there is often a feeling of “information overload” or inundation when facing the process of quantitative decision making.

In this project, I chose Atmospheric Carbon Dioxide dataset, Extreme Weather Records by State in US dataset from State Climate Extremes Committee (SCEC), and Global Temperature Anomalies. The goal is to study the effect of extreme temperatures and their effects predominantly within the United States but also globally.

Atmospheric Carbon Dioxide


In this graph, there is a very obvious trends that as the years moving forward, the carbon dioxide growth rate is increasing. With that being said, the level of CO2 in the atmosphere is increasing year by year, which in turn will result in some climate changes especially in the global temperature.

Highest Temperature


As reflected in the bar chart, of all the states in the US, California, Arizona and Nevada seem to have the highest temperature records: the highest temperature over time is 134 degrees F in California, followed by 128 degrees F in Arizona, and 125 degrees F in Nevada.

The dataset is from Extreme Temperature Records by state on NOAA website. Source : https://www.climate.gov/maps-data/dataset/extreme-weather-records-state-data-table

Lowest Temperature


As reflected in the bar chart, of all the states in the US, Alaska, Montana and Wyoming seem to have the lowest temperature records: the highest temperature over time is - 80 degrees F in Alaska, followed by -70 degrees F in Montana, and -66 degrees F in Wyoming.

Global Temperature Anomalies


Looking at the temperature anomalies globally, one of the most obvious signals of climate change is the rise in global average temperature over the past several decades. Comparing the average temperature of land, ocean, or land and ocean combined for any month or multi-month period to the average temperature for the same period over the year indicated that current temperature conditions are warmer than the past.

The Global Temperature Anomalies data can be obtained from Climate.gov website. A combined global land and ocean temperature anomaly dataset was created after the temperature collected from manual and automated weather stations.

Source : https://www.climate.gov/maps-data/dataset/global-temperature-anomalies-graphing-tool

---
title: "ANLY 512 Lab 2"
author: "Xingchao Zhou"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    source: embed
    orientation: columns
    vertical_layout: fill
    df_print: paged
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flexdashboard)
library(knitr)
library(ggplot2)
library(dplyr)
library(plotly)
```


### Introduction - Climate Changes

Climate change and science has been an issue for discussion and debate for at least the last decade. Climate data collection is currently being collected for areas all over the world. Policy decisions are based on the most recent analysis conducted on data extracted from huge online repositories of this data. Due to the inherent growth in the electronic production and storage of information, there is often a feeling of “information overload” or inundation when facing the process of quantitative decision making. 

In this project, I chose Atmospheric Carbon Dioxide dataset, Extreme Weather Records by State in US dataset from State Climate Extremes Committee (SCEC), and Global Temperature Anomalies. The goal is to study the effect of extreme temperatures and their effects predominantly within the United States but also globally.


```{r}
setwd("C:/Users/xingc/Documents/Harrisburg/Fall 2019/512 Data Visilization - Thursday/HW/HW5 - Lab 2")
climatedata <- read.csv("Lab 2 Data.csv")
```


### Atmospheric Carbon Dioxide


```{r}
# get data
acd = read.table("ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_mm_mlo.txt", header = FALSE, col.names = c("Year","Month","Decimal_Date","Average","Interpolated","Trend","Days"), skip = 70)

# reformat date
acd$Average = replace(acd$Average, acd$Average == -99.99, NA)
acd$Days = replace(acd$Days, acd$Days == -1, NA)
scaled_acd = acd
scaled_acd$Interpolated = scale(acd$Interpolated)
scaled_acd_time_series = ts(scaled_acd$Interpolated, frequency = 12, start = c(1958,3))

# plot
plot(scaled_acd_time_series, main = "Monthly Mean Atmospheric Carbon Dioxide Growth Rate", xlab = "Year", ylab="Monthly Mean Atmospheric Carbon Dioxide Level")

```

***
In this graph, there is a very obvious trends that as the years moving forward, the carbon dioxide growth rate is increasing. With that being said, the level of CO2 in the atmosphere is increasing year by year, which in turn will result in some climate changes especially in the global temperature.


### Highest Temperature


```{r}
#Statewide highest temperatures

MaxTemp <- subset(climatedata, climatedata$Element == "All-Time Maximum Temperature")


MaxTempFinal <- MaxTemp [!duplicated(MaxTemp[c(1,4)]),]


Max_temp_g = ggplot(MaxTempFinal, aes(x = State, y = Value)) + 
  geom_bar(aes(fill=State),stat="identity",width = 0.9, 
           position = position_dodge()) + theme_minimal() + 
  xlab("State") + ylab("Temperature (degrees F)") +
  theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      plot.background = element_blank()) + 
  ggtitle("Statewide Highest Temperatures Recorded")
ggplotly(Max_temp_g)
```

*** 
As reflected in the bar chart, of all the states in the US, California, Arizona and Nevada seem to have the highest temperature records: the highest temperature over time is 134 degrees F in California, followed by 128 degrees F in Arizona, and 125 degrees F in Nevada.

The dataset is from Extreme Temperature Records by state on NOAA website. Source : https://www.climate.gov/maps-data/dataset/extreme-weather-records-state-data-table



### Lowest Temperature


```{r}
#Statewide lowest temperatures

MinTemp <- subset(climatedata, climatedata$Element == "All-Time Minimum Temperature")


MinTempFinal <- MinTemp [!duplicated(MinTemp[c(1,4)]),]


Min_temp_g = ggplot(MinTempFinal, aes(x = State, y = Value)) + 
  geom_bar(aes(fill=State),stat="identity",width = 0.9, 
           position = position_dodge()) + theme_minimal() + 
  xlab("State") + ylab("Temperature (degrees F)") +
  theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      plot.background = element_blank()) + 
  ggtitle("Statewide Lowest Temperatures Recorded")
ggplotly(Min_temp_g)

```

***
As reflected in the bar chart, of all the states in the US, Alaska, Montana and Wyoming seem to have the lowest temperature records: the highest temperature over time is - 80 degrees F in Alaska, followed by -70 degrees F in Montana, and -66 degrees F in Wyoming.

### Global Temperature Anomalies 


```{r}
globaldata<-read.csv("Lab 2 Data 2.csv")

global = ggplot(globaldata, aes(x = Year, y = Value)) + 
  geom_line(color='steelblue') + 
  xlab("Year") + ylab("Value") +
  theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      plot.background = element_blank()) + 
  ggtitle("Global Temperature Anomalies")
ggplotly(global)
```

***
Looking at the temperature anomalies globally, one of the most obvious signals of climate change is the rise in global average temperature over the past several decades. Comparing the average temperature of land, ocean, or land and ocean combined for any month or multi-month period to the average temperature for the same period over the year indicated that current temperature conditions are warmer than the past.

The Global Temperature Anomalies data can be obtained from Climate.gov website. A combined global land and ocean temperature anomaly dataset was created after the temperature collected from manual and automated weather stations.

Source : https://www.climate.gov/maps-data/dataset/global-temperature-anomalies-graphing-tool