Introduction

Overview

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. As an analyst your job will often be to explore large data sets and develop questions or ideas from visualizations of those data sets.

The ability to synthesize large data sets using visualizations is a skill that all data scientists should have. In addition to this data scientists are called upon to present data syntheses and develop questions or ideas based on their data exploration. This lab should take you through the major steps in data exploration and presentation.

Objective

The objective of this laboratory is to survey the available data, plan, design, and create an information dashboard/presentation that not only explores the data but helps you develop questions based on that data exploration. To accomplish this task you will have to complete a number of steps:

  1. Identify what information interests you about climate change.
  2. Find, collect, organize, and summarize the data necessary to create your data exploration plan.
  3. Design and create the most appropriate visualizations (no less than 5 visualizations) to explore the data and present that information.
  4. Finally organize the layout of those visualizations into a dashboard (use the flexdashboard package) in a way that shows your path of data exploration.
  5. Develop four questions or ideas about climate change from your visualizations.

Source: [NOAA] (https://www.ncdc.noaa.gov/cag/statewide/mapping)

Statewide Extreme Temperature 1980 - 2022

Row

Statewide Maximum Temperature


From this chart, we can see that California has the highest Maximum temperature in the US, followed by Arizona. All the top 10 states are located in middle or west of the US.

Row

Statewide Minimum Temperature

Of all the states in the US, Alaska keeps the record of having the lowest temperature, follow by Wyoming. It makes sense that with increasing latitude temperature is decrease.

US Climate Disasters cost by State in $B from 1980 - 2022

Row

Statewide Wildfire Cost

The map displays the total cost of billion-dollar wildfires for each affected state. Clearly, California has the highest cost, which aligns with the results shown in the first graph that California has a record of high temperatures.

Row

Statewide Winter Storm Cost

The map shows the total cost of billion-dollar winter storms for each affected state. Texas was the state hardest hit by the winter storm.

Annual Mean Temperature Change in the United States

Row

Row

The graph displays the average annual and five-year air temperature for the contiguous 48 states in the United States, which is only 1.6% of the Earth’s surface, relative to the average temperature between 1895 and 2022. This information provides a visual representation of the temperature trends and fluctuations in the country over a prolonged period, allowing for the assessment of climate change and its impacts. By comparing the current temperature to the average temperature, we can better understand the changes that are taking place and their effects on the environment and society.

Average Precipitation from 1895 - 2022

Row

Row

The average precipitation data from 1895 to 2022 provides insight into changing rainfall patterns over time and their impact on the environment and society. It helps predict water availability and inform water management strategies for a sustainable future.

---
title: "ANLY 512 Lab 2"
author: "Zhuoqiang Jia"
date: "2/4/2023"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(ggplot2)
library(tidyverse)
library(readxl)
library(dplyr)
library(xts)
library(zoo)
library(ggrepel)
library(maps)
library(ggsn)
library(stats)

```

Introduction
=====================================
**Overview**

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. As an analyst your job will often be to explore large data sets and develop questions or ideas from visualizations of those data sets.

The ability to synthesize large data sets using visualizations is a skill that all data scientists should have. In addition to this data scientists are called upon to present data syntheses and develop questions or ideas based on their data exploration. This lab should take you through the major steps in data exploration and presentation.

**Objective**

The objective of this laboratory is to survey the available data, plan, design, and create an information dashboard/presentation that not only explores the data but helps you develop questions based on that data exploration. To accomplish this task you will have to complete a number of steps:

1.  Identify what information interests you about climate change.
2.  Find, collect, organize, and summarize the data necessary to create your data exploration plan.
3.  Design and create the most appropriate visualizations (no less than 5 visualizations) to explore the data and present that information.
4.  Finally organize the layout of those visualizations into a dashboard (use the flexdashboard package) in a way that shows your path of data exploration.
5.  Develop four questions or ideas about climate change from your visualizations.

Source: [NOAA] (https://www.ncdc.noaa.gov/cag/statewide/mapping)

**Statewide Extreme Temperature 1980 - 2022**
=======================================================================

Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------

### Statewide Maximum Temperature {.no-padding}

```{r,echo = FALSE, message = FALSE, fig.width=10}

Record <- read.csv("/Users/zhuoqiangjia/Desktop/HU/2022fall/ANLY 512-90/Assignment/Lab_2/state_records.csv")

max_Temp <- Record[Record$Element == "All-Time Maximum Temperature" ,c(1,2,3) ]
max_Temp_unique<- unique(max_Temp)

newdata <- max_Temp_unique[order(-as.numeric(max_Temp_unique$Value)), ]

newdata[1:10,] %>%
  mutate(State = fct_reorder(State, Value))%>%
  ggplot(aes(x = State, y = Value)) + 
  geom_bar(stat="identity",width = 0.80, aes(fill=State)) + 
  scale_fill_brewer(palette="Spectral")+
  coord_flip()+
  xlab("State") + 
  ylab("Highest Recorded Temperature in F") +
  theme_classic()+
  theme(legend.position="none")+
  geom_text(aes(label=Value), hjust=-0.1, size=2.8)+
  ggtitle("10 States with Highest Temperature Record in the USA")


```

------------------------------------------------------------------------

####
From this chart, we can see that California has the highest Maximum temperature in the US, followed by Arizona. All the top 10 states are located in middle or west of the US.

Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------

### Statewide Minimum Temperature {.no-padding}

```{r,echo = FALSE, message = FALSE,fig.width=10}

Record <- read.csv("/Users/zhuoqiangjia/Desktop/HU/2022fall/ANLY 512-90/Assignment/Lab_2/state_records.csv")

min_Temp <- Record[Record$Element == "All-Time Minimum Temperature" ,c(1,2,3) ]
min_Temp_unique<- unique(min_Temp)

newdata2 <- min_Temp_unique[order(-as.numeric(min_Temp_unique$Value),decreasing = TRUE), ]

newdata2[1:10,] %>%
  mutate(State = fct_reorder(State, Value))%>%
  ggplot(aes(x = State, y = Value)) + 
  geom_bar(stat="identity",width = 0.80, aes(fill=State)) + 
  scale_fill_brewer(palette="Paired")+
  coord_flip() +
  xlab("State") + 
  ylab("Lowest Recorded Temperature in F") +
  theme_classic()+
  theme(legend.position="none")+
  theme(axis.text=element_text(size=9),
        axis.title=element_text(size=12,face="bold"))+
  geom_text(aes(label=Value), vjust=+1.2, size=2.8)+
  ggtitle("10 States with lowest Temperature Record in the USA")


```

####
Of all the states in the US, Alaska keeps the record of having the lowest temperature, follow by Wyoming. It makes sense that with increasing latitude temperature is decrease.


**US Climate Disasters cost by State in \$B from 1980 - 2022**
=======================================================================

Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------
### Statewide Wildfire Cost {.no-padding}
```{r,echo = FALSE, message = FALSE, fig.width=10}

StormData <- read.csv("/Users/zhuoqiangjia/Desktop/HU/2022fall/ANLY 512-90/Assignment/Lab_2/state-cost-data.csv")

names(StormData) = c("state", "drought", "flooding", "freeze", "severe storm","tropical cyclone","wildfire","winter_storm","StateL")

states = map_data("state")  

StormData$region = tolower(StormData$StateL)
states = merge(states, StormData, by="region", all.x=T)

ggplot(states, aes(x = long, y = lat, group = group,fill=wildfire))+
  geom_polygon(color = "white") +
  scale_fill_viridis_c(option = "D")+
  theme_void()+
  labs(title="Statewide Wildfire Cost in $B from 1980 - 2022")


```

The map displays the total cost of billion-dollar wildfires for each affected state. Clearly, California has the highest cost, which aligns with the results shown in the first graph that California has a record of high temperatures.

Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------
### Statewide Winter Storm Cost {.no-padding}

```{r,echo = FALSE, message = FALSE, fig.width=10}


ggplot(states, aes(x = long, y = lat, group = group,fill=winter_storm))+
  geom_polygon(color = "white") +
  scale_fill_viridis_c(option = "C")+
  theme_void()+
  labs(title="Statewide Winter Storm Cost in $B from 1980 - 2022")

```

The map shows the total cost of billion-dollar winter storms for each affected state. Texas was the state hardest hit by the winter storm.

**Annual Mean Temperature Change in the United States**
=======================================================================
Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------

```{r,echo = FALSE, message = FALSE,fig.width=10}

USTemp <- read.csv("/Users/zhuoqiangjia/Desktop/HU/2022fall/ANLY 512-90/Assignment/Lab_2/1895-2022.csv")

cleanup <- theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank(), 
                panel.background = element_blank(), 
                axis.line.x = element_line(color = 'black'), 
                axis.line.y = element_line(color = 'black'), 
                legend.key = element_rect(fill = 'white'), 
                text = element_text(size = 15)) 

data <- USTemp$Annual_Mean
library(stats)
Lowess.5 <- lowess(data,f=1/10)

ggplot(data = USTemp,aes(x=Year)) + 
  geom_line(aes(y = Annual_Mean, colour = "Annual_Mean")) +
  geom_line(aes(y = Lowess.5$y, colour = "Lowess Smoothing")) +
  scale_colour_manual("", 
                      breaks = c("Annual_Mean", "Lowess Smoothing"),
                      values = c("blue", "red")) +
  xlab('Year') +
  ylab('Temperature Anomaly w.r.t.1895-2022 (C)')+
  ggtitle("US Temperature")
```

Row {.tabset .tabset-fade data-width=300}
-----------------------------------------------------------------------
The graph displays the average annual and five-year air temperature for the contiguous 48 states in the United States, which is only 1.6% of the Earth's surface, relative to the average temperature between 1895 and 2022. This information provides a visual representation of the temperature trends and fluctuations in the country over a prolonged period, allowing for the assessment of climate change and its impacts. By comparing the current temperature to the average temperature, we can better understand the changes that are taking place and their effects on the environment and society.

**Average Precipitation from 1895 - 2022**
=======================================================================
Row {.tabset .tabset-fade data-width=600}
-----------------------------------------------------------------------

```{r,echo = FALSE, message = FALSE,fig.width=10}

Precipitation <- read.csv("/Users/zhuoqiangjia/Desktop/HU/2022fall/ANLY 512-90/Assignment/Lab_2/1895-2022 (1).csv")

ggplot(data = Precipitation,aes(x=Year,y=Precipitation)) +
  geom_point(color = "dark green") +
  geom_line() +
  ggtitle("Average Precipitation from 1895 - 2022") + 
  labs(x= "Year", y= "Average Precipitation (mm)")

```

Row {.tabset .tabset-fade data-width=300}
-----------------------------------------------------------------------
The average precipitation data from 1895 to 2022 provides insight into changing rainfall patterns over time and their impact on the environment and society. It helps predict water availability and inform water management strategies for a sustainable future.