Introduction

Row

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.

Row

Questions

In 2021, we have seen a lot of tremendous natural disasters all over the world. The result of global warming is more and more serious. Therefore, I want to explore global warming in my Lab 2 work. Here is a list of questions I have:

Q1: If there is global warming during the last century?

Yes, we can get the answer directly from the Global temperature change graph. From 1900 to 2000, the global temperature has raised almost 1.5 Celsius degrees. Also, the trend of getting higher global temperature has become more and more evident during recent 2 decades.

Q2: What is the temperature of United States? By looking at the average temperature of the U.S. is between 50F and 60F.

Q3:What are the top 3 states on the main land with the highest average temperature? The 3 states are FL, TX, and LA.

Q4:If global warming cause sea level rise? Yes, both the sea level at MA and TX have raised over the last century during global warming.

Summary

I created 5 data visualization graphs from global temperature change, to the temperature of U.S., and to the sea level change. I am glad to be able to collect data which could cover over 100 years. The visualization shows that there are more and more people are affected by the sea level rise caused by global warming. In additional, sea level raising is not just a regional issue but a global issue. We will lose more and more lands. It is very important for us to take actions to stop the global warning trend.

Global Temperature Change

Row

Figure 1. Global Temperature through the Years

Average Temperature (US)

Row

Maximum Temperature - (US)

Row

Sea level (Boston, MA)

Row

sea level (8443970 Boston, Massachusetts)

Sea level (Galveston, TX)

Row

sea level (8771450 Galveston Pier 21, Texas)

---
title: "ANLY 512 Lab 2 - Data Exploration and Analysis"
author: "Ruohai Wang"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
  
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dygraphs)
library(maps)
library(ggmap)
library(dplyr)
library(ggplot2)
library(maptools)
library(rgdal)
library (RCurl)
library(tidyverse)
library(plotly)
library(scatterpie)
library(rnoaa)
library(usmap)
library(mapproj)
```


Introduction
===========================================

Row {}
-----------------------------------------------------------------------

### 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. 

Row {}
-----------------------------------------------------------------------

### Questions
In 2021, we have seen a lot of tremendous natural disasters all over the world. The result of global warming is more and more serious. Therefore, I want to explore global warming in my Lab 2 work. Here is a list of questions I have:

Q1: If there is global warming during the last century?

Yes, we can get the answer directly from the Global temperature change graph. From 1900 to 2000, the global temperature has raised almost 1.5 Celsius degrees. Also, the trend of getting higher global temperature has become more and more evident during recent 2 decades.

Q2: What is the temperature of United States?
By looking at the average temperature of the U.S. is between 50F and 60F. 

Q3:What are the top 3 states on the main land with the highest average temperature?
The 3 states are FL, TX, and LA.

Q4:If global warming cause sea level rise?
Yes, both the sea level at MA and TX have raised over the last century during global warming. 


Summary

I created 5 data visualization graphs from global temperature change, to the temperature of U.S., and to the sea level change. I am glad to be able to collect data which could cover over 100 years. The visualization shows that there are more and more people are affected by the sea level rise caused by global warming. In additional, sea level raising is not just a regional issue but a global issue. We will lose more and more lands. It is very important for us to take actions to stop the global warning trend. 



Global Temperature Change
===========================================

Row {}
-----------------------------------------------------------------------

### Figure 1. Global Temperature through the Years

```{r, echo=FALSE}
#Get information
Global_Temperature = read.table("http://climate.nasa.gov/system/internal_resources/details/original/647_Global_Temperature_Data_File.txt", header = FALSE, col.names = c("Year","Annual_Mean","Five_Year_Mean"),skip = 5, nrows=136)
Global_Temperature[,3] = as.numeric(as.character(Global_Temperature[,3]))
scaled_Global_Temperature = Global_Temperature
scaled_Global_Temperature[,2] = scale(Global_Temperature$Annual_Mean)
scaled_Global_Temperature[,3] = scale(Global_Temperature$Five_Year_Mean)
Lowess_smoothing = ts(scaled_Global_Temperature$Five_Year_Mean, frequency = 1, start=c(1880))
Annual_Mean = ts(scaled_Global_Temperature$Annual_Mean, frequency = 1, start=c(1880))
Temperatures <- cbind(Lowess_smoothing, Annual_Mean)


#Plot
dygraph(Temperatures, main = "Global Temperature Anomaly", xlab = "Year", ylab="Temperature Anomaly (C)") %>%
dyRangeSelector() %>%
dyLegend(width = 500, show = "onmouseover") %>%
dyOptions(drawGrid = FALSE) %>%
dyOptions(colors = RColorBrewer::brewer.pal(3, "Set2"))
```

Average Temperature (US)
===================================== 
Row {}
-------------------------------------
```{r,echo = FALSE, message = FALSE}
data <- read.csv(url("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tavg-201503-60.csv"),skip=3)

state = map_data("state")
data$region = tolower(data$Location)
temp = merge(state, data, by="region", all=T)
temp<-temp[-6]
temp<-drop_na(temp)

mt = ggplot(temp, aes(x = long, y = lat, group = group, fill = Value))+geom_polygon(color = "white")
mt = mt + scale_fill_gradient(name = "Temperature(F)",  low = "White", high = "Pink" , na.value="white") + labs(x="Longitude",y="Latitude", title = "Average Temperature across each state during the last 60 months")
mt + coord_map()

```

Maximum Temperature - (US)
===================================== 
Row {}
-------------------------------------
```{r,echo = FALSE, message = FALSE}
data <- read.csv(url("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tmax-201501-60.csv"),skip=3)

state = map_data("state")
data$region = tolower(data$Location)
temp = merge(state, data, by="region", all=T)
temp<-temp[-6]
temp<-drop_na(temp)

mt = ggplot(temp, aes(x = long, y = lat, group = group, fill = Value))+geom_polygon(color = "white")
mt = mt + scale_fill_gradient(name = "Temperature(F)",  low = "White", high = "Red" , na.value="white") + labs(x="Longitude",y="Latitude" , title = "Maximum Temperature across each state during the last 60 months")
mt + coord_map()
```

Sea level (Boston, MA)
=====================================
Row {}
-------------------------------------
### sea level (8443970 Boston, Massachusetts)
```{r, echo=FALSE}

seaLevel8443970 = read.table("https://tidesandcurrents.noaa.gov/sltrends/data/8443970_meantrend.txt", header = TRUE, col.names = c("Year","Month","Linear_Trend","High_Conf","Low_Conf","other","other2"),fill=T)
a = data.frame(seaLevel8443970)[1:3]
x <- list(title="Year")
y <- list(title="Sea Level Trends")
plot_ly(a, x = ~Year, y = ~Linear_Trend, type="scatter", mode="lines")%>% layout(xaxis=x, yaxis=y, title="Sea Level of Boston, Massachusetts between 1940 and 2020")

```

Sea level (Galveston, TX)
===================================== 
Row {}
-------------------------------------
### sea level (8771450 Galveston Pier 21, Texas)
```{r, echo=FALSE}

seaLevel8771450 = read.table("https://tidesandcurrents.noaa.gov/sltrends/data/8771450_meantrend.txt", header = TRUE, col.names = c("Year","Month","Linear_Trend","High_Conf","Low_Conf","other","other2"),fill=T)
a = data.frame(seaLevel8771450)[1:3]
x <- list(title="Year")
y <- list(title="Sea Level Trends")
plot_ly(a, x = ~Year, y = ~Linear_Trend, type="scatter", mode="lines")%>% layout(xaxis=x, yaxis=y, title="Sea Level of Galveston Pier 21, Texas between 1940 and 2020")