Introduction

Climate change and science has been an issue for discussion and debate for at least the last decade.

Climate change is all over the 50 states, I have choose the statewide average temperature to do the analysis.

Data is based on the time period from 1991-2000.

Source: NOAA

Analysis

Row

July 2018 Contiguous U.S. Statewide Average Temperature

July 2018 Mean Value

Row

July 2018 Statewide Average Temperature Anomaly

July 2018 Anomaly (1901-2000 base period)

Conclusion

In the bar chart of mean tempature, it shows that:

Average Temperature:

State-wide averages of annual temperatures range from a high of 84.4 degrees Fahrenheit in Texas to a low of 67 °F in Montana.

Because the actual temperature are often difficult to gather. Some areas in the world have few temperature measurement stations, for example, remote jungles and deserts, and temperatures must be estimated over large regions.

So, here comes the anomaly!

Anomaly:

What is temperature anomalies?

That is the difference between the long-term average temperature and the temperature that is actually occurring. In other words, the long-term average temperature is one that would be expected; the anomaly is the difference between what you would expect and what is happening.

A positive anomaly means that the temperature was warmer than normal; a negative anomaly indicates that the temperature was cooler than normal.

As we can see in the bar chart:

-California has the highest level of anomaly 5, which means California is the warmest one during the period.

-Nebraska has the lowest level -1.1, which means Nebraska is the coldest one during the same period.

Climate Changes:

From the map of statewide average temperature, we can see the temperature of south area is higher than the others;

From the map of statewide anomaly, we can see the west or southwest has a higher level of anomaly than the others;

Weather is the general condition of the atmosphere at a particular time and place, with regard to the temperature, moisture, and other factors. Climate is the long-term patterns of weather in a particular region, including temperatures, rain, snow, and other factors. The word anomaly is anything that departs from the regular pattern, general rule, or usual method. Therefore, day-by-day anomalies are called weather, while climate is the general trend of weather, based on statistical data accumulated over time. Climate is influenced by the sun, by the atmosphere, and by the ways that the atmosphere and the ocean transport heat. For a particular region the elevation, terrain, distance from the ocean latitude, and other factors must also be considered. Humans can also affect climate with air pollution.

---
title: "ANLY 512 Lab 2"
author: "Linfang Li"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    source_code: embed
    vertical_layout: fill
---

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

Climate change and science has been an issue for discussion and debate for at least the last decade.

Climate change is all over the 50 states, I have choose the statewide average temperature to do the analysis.

Data is based on the time period from 1991-2000.

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

Analysis
=======================================================================
Row {.tabset data-width=600}
-----------------------------------------------------------------------
### July 2018 Contiguous U.S. Statewide Average Temperature {.no-padding}

```{r,echo = FALSE, message = FALSE,fig.width=12}
state_avg_temp <- read.csv("Statewide Average Temp.csv")
names(state_avg_temp) = c("Location.ID", "Location", "Value", "Rank", "Mean","Anomaly")
states = map_data("state")  
state_avg_temp$region = tolower(state_avg_temp$Location)
states = merge(states, state_avg_temp, by="region", all.x=T)

h <- ggplot(states, aes(x = long, y = lat, group = group, fill = Value))+
  geom_polygon(color = "white")
h <- h + scale_fill_gradient(name = "degrees F", low = "#feceda", high = "#c81f49", guide = "colorbar", na.value="black") 
h <- h + labs(title="July 2018 Statewide Average Temperature") + coord_map() 
ggplotly(h, height = 700, width = 750)
```

### July 2018 Mean Value

```{r, echo = FALSE, message = FALSE}
Max_temp_g=ggplot(state_avg_temp, aes(x = reorder(Location,-Value), y = Value)) + 
  geom_bar(aes(fill=Location),stat="identity",width = 0.9, 
           position = position_dodge(1.0)) + theme_minimal() + 
  xlab("State") + ylab("Mean Temp (degrees F)") +
  theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      plot.background = element_blank()) + 
  ggtitle("Bar Chart of Mean Temp, July 2018")
ggplotly(Max_temp_g)
```


Row {.tabset .tabset-fade}
-----------------------------------------------------------------------
### July 2018 Statewide Average Temperature Anomaly {.no-padding}

```{r,echo = FALSE, message = FALSE,fig.height=8}
p <- ggplot(states, aes(x = long, y = lat, group = group, fill = Anomaly))+
  geom_polygon(color = "white")
p <- p + scale_fill_gradient(name = "Anomaly", low = "#33ff99", high = "#339999", guide = "colorbar", na.value="black") 
p <- p + labs(title="Statewide Average Temperature Anomaly") + coord_map() 
ggplotly(p)
```

### July 2018 Anomaly (1901-2000 base period)

```{r, echo = FALSE, message = FALSE}
Min_temp_g=ggplot(state_avg_temp, aes(x = reorder(Location,-Anomaly), y = Anomaly)) + 
  geom_bar(aes(fill=Location),stat="identity",width = 0.9, 
           position = position_dodge(1.0)) + theme_minimal() + 
  xlab("State") + ylab("Mean Temp (degrees F)") +
  theme(axis.text.x=element_blank(),
      axis.ticks.x=element_blank(),
      plot.background = element_blank()) + 
  ggtitle("Bar Chart of Anomaly based 1901-2000")
ggplotly(Min_temp_g)
```

Conclusion
====================================

In the bar chart of mean tempature, it shows that:

**Average Temperature:**

State-wide averages of annual temperatures range from a high of 84.4 degrees Fahrenheit in Texas to a low of 67 °F in Montana. 

Because the actual temperature are often difficult to gather. Some areas in the world have few temperature measurement stations, for example, remote jungles and deserts, and temperatures must be estimated over large regions.

So, here comes the anomaly!

**Anomaly:**

What is temperature anomalies?

That is the difference between the long-term average temperature and the temperature that is actually occurring. In other words, the long-term average temperature is one that would be expected; the anomaly is the difference between what you would expect and what is happening.

A positive anomaly means that the temperature was warmer than normal; a negative anomaly indicates that the temperature was cooler than normal.

As we can see in the bar chart:

-California has the highest level of anomaly 5, which means California is the warmest one during the period.

-Nebraska has the lowest level -1.1, which means Nebraska is the coldest one during the same period.

**Climate Changes:**

From the map of statewide average temperature, we can see the temperature of south area is higher than the others;

From the map of statewide anomaly, we can see the west or southwest has a higher level of anomaly than the others;

Weather is the general condition of the atmosphere at a particular time and place, with regard to the temperature, moisture, and other factors. Climate is the long-term patterns of weather in a particular region, including temperatures, rain, snow, and other factors. The word anomaly is anything that departs from the regular pattern, general rule, or usual method. Therefore, day-by-day anomalies are called weather, while climate is the general trend of weather, based on statistical data accumulated over time. Climate is influenced by the sun, by the atmosphere, and by the ways that the atmosphere and the ocean transport heat. For a particular region the elevation, terrain, distance from the ocean latitude, and other factors must also be considered. Humans can also affect climate with air pollution.