Global Temperature Analysis

Column 1

Global Temperature between 1900 and 2019

Column 2

Questions + Analysis

Question 1: How does the global temperature trend in recent years?

Global warning has been a concerning issue in recent years, and from the graph on the left, we can see that the temperature around the globe is, indeed, increasing year over year since 1900. The positive slope also suggests that it is likely for the increase to continue in the future. Therefore, we must research the causes and potential opportunities to mitigate the risks. In addition to the rise of temperature, we are going to measure the effect global warming brings to the changes in sea level, carbon dioxide, and precipitation.

Question 2: How does global warming affect daily atmospheric CO2?

In Figure 2, we can see that daily average reading for atmospheric CO2 on the planet has been increasing since 1960. The increase in CO2 is one of many phenomena of global warming. More specifically, the increase is due to the burning of fossil fuels such as coal, oil and gas releases greenhouse gases into Earth’s atmosphere and oceans.

Question 3: How does global warming affect sea level changes?

Figure 3 showcases the global sea-level changes over the years from 1900 to 2020. As we can see from the graph that the sea level is higher in recent years and has experienced more drastic fluctuations than before.

Question 4: Does global warming affect global sea levels the same way it does to specific areas?

Figure 4,5 and 6 are more granular graphs of specific areas with regards to precipitation and sea level changes. From graph 4 and 5, we can see that the sea level in both Texas and Massachusetts has been rising with more drastic positive increase each year.

Question 5: How does global warming affect precipitation?

Graph 6 showcases Pennsylvania’s monthly rain record in 2010 and 2019. In comparison of the amount of rain in 2010 and 2019, there are more frequent rain volume per month in 2019 than 2010. One of recently published research mentioned that global warming is shifting the amount of rain from one location of the US to other location, causing drought situation in one place, and severe flooding issues at other. However, in this case, it seems like global warming increases the rain in Pennsylvania, or at least when compared 2010 and 2019.

Carbon Dioxide + Sea Level Changes

Column 1

Carbon Dioxide Between 1960 and 2020

Column 2

Sea Level Changes between 1900 and 2020

More Granular Looks

Column 1

sea level (8771450 Galveston Pier 21, Texas)

sea level (8443970 Boston, Massachusetts)

Column 2

2010 Precipitation

2019 Precipitation

---
title: "Lab2 - Data Exploration and Analysis Laboratory"
output:
  flexdashboard::flex_dashboard:
      social: menu
      source: embed
  
---

```{r setup, include=FALSE}

library(flexdashboard)
library(dygraphs)
library(readxl)
library(rnoaa)


```


# Global Temperature Analysis {data-icon="fa-list"} 

## Column 1

### Global Temperature between 1900 and 2019

```{r, echo=FALSE}

Global_Temperature <- read_excel("Global Temperature.xlsx") 

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)

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

```

## Column 2

### Questions + Analysis 

Question 1: How does the global temperature trend in recent years?

Global warning has been a concerning issue in recent years, and from the graph on the left, we can see that the temperature around the globe is, indeed, increasing year over year since 1900. The positive slope also suggests that it is likely for the increase to continue in the future. Therefore, we must research the causes and potential opportunities to mitigate the risks. In addition to the rise of temperature, we are going to measure the effect global warming brings to the changes in sea level, carbon dioxide, and precipitation.

Question 2: How does global warming affect daily atmospheric CO2?

In Figure 2, we can see that daily average reading for atmospheric CO2 on the planet has been increasing since 1960. The increase in CO2 is one of many phenomena of global warming. More specifically, the increase is due to the burning of fossil fuels such as coal, oil and gas releases greenhouse gases into Earth's atmosphere and oceans.

Question 3: How does global warming affect sea level changes?

Figure 3 showcases the global sea-level changes over the years from 1900 to 2020. As we can see from the graph that the sea level is higher in recent years and has experienced more drastic fluctuations than before.

Question 4: Does global warming affect global sea levels the same way it does to specific areas?

Figure 4,5 and 6 are more granular graphs of specific areas with regards to precipitation and sea level changes. From graph 4 and 5, we can see that the sea level in both Texas and Massachusetts has been rising with more drastic positive increase each year.

Question 5: How does global warming affect precipitation?

Graph 6 showcases Pennsylvania's monthly rain record in 2010 and 2019. In comparison of the amount of rain in 2010 and 2019, there are more frequent rain volume per month in 2019 than 2010. One of recently published research mentioned that global warming is shifting the amount of rain from one location of the US to other location, causing drought situation in one place, and severe flooding issues at other. However, in this case, it seems like global warming increases the rain in Pennsylvania, or at least when compared 2010 and 2019. 


# Carbon Dioxide + Sea Level Changes {data-icon="map-list"}  

## Column 1

### Carbon Dioxide Between 1960 and 2020

```{r, echo=FALSE}

Carbon_Dioxide <- 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","Number_Days"), skip = 70)

Carbon_Dioxide$Average <- replace(Carbon_Dioxide$Average, Carbon_Dioxide$Average == -99.99, NA)
Carbon_Dioxide$Number_Days <- replace(Carbon_Dioxide$Days, Carbon_Dioxide $Number_Days == -1, NA)

scaled_Carbon_Dioxide <- Carbon_Dioxide 

scaled_Carbon_Dioxide_time_series2 <- ts(Carbon_Dioxide$Average, frequency = 12, start = c(1958,3))

dygraph(scaled_Carbon_Dioxide_time_series2, main = "Carbon Dioxide Direct Measurements", xlab = "Year", ylab="CO2 (parts per million)") %>%
  dyRangeSelector() %>%
  dyLegend(width = 500, show = "onmouseover") %>%
  dyOptions(drawGrid = FALSE) %>%
  dyOptions(fillGraph = TRUE, fillAlpha = 0.6)

```

## Column 2

### Sea Level Changes between 1900 and 2020

```{r, echo=FALSE}

library(plotly)

seaLevel611 = read.table("https://tidesandcurrents.noaa.gov/sltrends/data/611-010_meantrend.txt", header = TRUE, col.names = c("Year","Month","Linear_Trend","High_Conf","Low_Conf","other","other2"),fill=T)
seaLevel611 = seaLevel611[1:3]
a = data.frame(seaLevel611)
x <- list(title="Year", titlefont=list(family="Courier New",size=16))
y <- list(title="NOAA Sea Level (Meters)", titlefont=list(family="Courier New",size=16))
plot_ly(a, x = ~Year, y = ~Linear_Trend, type="scatter", mode="lines") %>% layout(xaxis=x, yaxis=y, title="Global Sea Level Changes between 1900 and 2020")

```


# More Granular Looks {data-icon="fa-list"} 

## Column 1

### 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")

```

### 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")

```

## Column 2 {.tabset .tabset-fade}

### 2010 Precipitation

```{r, echo=FALSE}

library(devtools)
library(rnoaa)
library(lawn)

options(noaakey = "ouWMpKQfVPZcIlqJpnVxZBfpiTBPEOOP")


out <- ncdc(datasetid='GHCND', stationid='GHCND:USC00363698', datatypeid='PRCP', startdate = '2010-01-01', enddate = '2010-12-31', limit=500)
ncdc_plot(out, breaks="1 month", dateformat="%d/%m") + theme(axis.text.x=element_text(angle=45, hjust=1)) + labs(title = "Pennsylvania Precipitation in 2010", x = "Years", y = "Precipitation by Millimeters")

```

### 2019 Precipitation 

```{r, echo=FALSE}

library(devtools)

library(lawn)

options(noaakey = "ouWMpKQfVPZcIlqJpnVxZBfpiTBPEOOP")

out <- ncdc(datasetid='GHCND', stationid='GHCND:USC00363698', datatypeid='PRCP', startdate = '2019-01-01', enddate = '2019-12-31', limit=500)
ncdc_plot(out, breaks="1 month", dateformat="%d/%m") + theme(axis.text.x=element_text(angle=45, hjust=1)) + labs(title = "Pennsylvania Precipitation in 2019", x = "Years", y = "Precipitation by Millimeters")

```