state month avgtmp
1 AK APR -8
2 AK AUG 29
3 AK DEC -3
4 AK FEB -16
5 AK JAN -14
6 AK JUL 28
1.Low temperature is highly correlated with snowfall.New Hampshire has the most snowball.After that, Maini,NewYork,Vermont,Alaska have more snowball than other state,which makes sense. They have more days of low temperature days as well. It proved the snow is highly correlated with number of low temperature days.
---
title: "ANLY 512-Lab 2"
author: "Yingwen Xue"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(maps)
library(dplyr)
library(ggplot2)
```
# Intro {.sidebar}
In recent years, the frequency of extreme weather events increased sharply such as the heavy snow in texas. I am here interested in extrame cold weather and want to escape the cold weather.It is important for people like me to have a clear idea about where and when the extreme cold weather could be.
This dashboard contains the Extreme cold Weather Records by State by month data. It covers fromlate 19th century to 2018. It shows the all-time snow fall and low temperture statistic data in every state within Continental US.
Source: (https://www1.ncdc.noaa.gov/pub/data/ccd-data/csv/)
# Analysis
Row {data-height=750}
-----------------------------------------------------------------------
### USA statewise Lowest temperature of Record
```{r,echo = FALSE, message = FALSE}
library(sqldf)
library(sos)
lowtmp15 <-read.csv("F:/homework/512/lowtmp15.csv")
lowtmp15$Remove_all_space <- gsub('\\s+', '', lowtmp15$state)
group_lowtmp = sqldf('select Remove_all_space,avg(ANN) as avg from lowtmp15 group by Remove_all_space')
ggplot(group_lowtmp, aes(x = Remove_all_space, y = avg )) +
geom_point(aes(color = factor(Remove_all_space)))+
theme(legend.position="bottom", legend.direction="horizontal",legend.text=element_text(size=8),axis.text=element_text(size=6),
legend.title = element_blank()) +
guides(col = guide_legend(ncol = 50)) +
labs(x="Month", y="avgtmp") +
ggtitle("USA statewise Lowest temperature of Record")
##In this chart, New Hampshire has the lowest temperature among all the states.After that, Maini,NewYork,Vermont,Alaska have lower than other state.
```
### USA statewise avg Snowfall
```{r,echo = FALSE, message = FALSE}
library(sqldf)
library(sos)
avgsn <-read.csv("F:/homework/512/avgsnf15.csv")
avgsn$Remove_all_space_s <- gsub('\\s+', '', avgsn$state)
group_s = sqldf('select Remove_all_space_s,avg(ANN) as avg_s from avgsn group by Remove_all_space_s')
ggplot(group_s, aes(x = Remove_all_space_s, y = avg_s )) +
geom_point(aes(color = factor(Remove_all_space_s))) +
theme(legend.position="bottom", legend.direction="horizontal",axis.text=element_text(size=6),
legend.title = element_blank()) +
guides(col = guide_legend(ncol = 50)) +
labs(x="Month", y="temperature") +
ggtitle("USA statewise avg Snowfall")
```
### Most cold city avgtmp per Month
```{r,echo = FALSE, message = FALSE}
library(tidyr)
library(reshape2)
library(sqldf)
library(ggthemes)
library(sos)
library(raster)
keep=c('state', 'JAN',
'FEB', 'MAR', 'APR', 'MAY',
'JUN', 'JUL', 'AUG','SEP','OCT','NOV','DEC')
lowtmpMonth=lowtmp15[,(names(lowtmp15) %in% keep)]
g_lowtmpMonth <- gather(lowtmpMonth, month, tmp, -state)
group_t_m = sqldf('select state,month,avg(tmp) as avgtmp from g_lowtmpMonth group by state,month')
new_data <- trim(group_t_m)
new_data$month <-factor(new_data$month,
levels = c('JAN','FEB', 'MAR', 'APR', 'MAY',
'JUN', 'JUL', 'AUG','SEP','OCT','NOV','DEC'))
AK <- new_data[new_data$state %in% c("NH","AK","ME","NY","VT","WY"),]
head(AK)
p1 <- ggplot() + theme_economist() + scale_colour_economist() +
theme(plot.title=element_text(family="OfficinaSanITC-Book"),
text=element_text(family="OfficinaSanITC-Book")) +
geom_line(aes(y = avgtmp, x = month, colour = state), size=1.5, data = AK,
stat="identity") +
theme(legend.position="bottom", legend.direction="horizontal",
legend.title = element_blank()) +
labs(x="Month", y="temperature") +
ggtitle("Most cold city avgtmp per Month")
p1
```
Row
-----------------------------------------------------------------------
### Conclusion
1.Low temperature is highly correlated with snowfall.New Hampshire has the most snowball.After that, Maini,NewYork,Vermont,Alaska have more snowball than other state,which makes sense. They have more days of low temperature days as well. It proved the snow is highly correlated with number of low temperature days.
2. Most city with low temperature follows similar trend with season changes.Most of them will have 5 months with temperture below 0 degree.