NUMBER OF STORMS BY BASIN

Row

NUMBER OF STORMS PER BASIN BY YEAR

PERCENTAGES OF STORMS PER BASIN BY YEAR

NUMBER OF STORMS PER BASIN BY YEAR with WIND GREATER THAN 75 PERCENTILE(3rd QUALNTILE)

Row

Storm Visualization Per Basin

Question 1: What is the distribution of storm per basin ?

As the first barchart shows, in general, 2014 is the year that has the most storm happened around all the basin. And the year of 2017 has the least of storms number (ignoring the missing data of EP,NA,NI)

If we take a look at the storm happened distribution, we will find the EP (east pacific basin) has the most storms happened in totall. On the contrary, NI(north indonesia basin) has the least number of storms. One more thing need to be mentioned, WP (west pacific basin) had the most amount of storms in 2015 which surpluses any year’s storms number among all the basin.

Question 2: Is there any difference from 2014 to 2017 per one specific basin ?

As the second barchart shows, When considering the percentage of storm number in each basin, it is clearly that Year 2014 and 2016 occupited almost the same propotion in each basin, while year 2015’s proportion is divered among different basins.SP (south pacific basin has the least and the west pacific basin has the most)

Question 3: whether Hurricane has the same distribution as storm in all basin?

TIPS: When wind speed is over 74 mph or faster, the storm could be considered as Hurricane. As meteorologists say campared with intense storm, hurricanes tend to stick around much longer, cover more ground and cause more damage. So it is also important to seperate hurricane charts in our study.

As it shows in the third graph, the hurricanes’ distribution generally looks the same as storm’s, and the total number is smaller than the storms’. The number of Hurricanes were not that high in both EP and SP basin as how storm’s data look. We can concluded that even though there were a lot storms happened in 2014 a lot of them were not that severe.

Row

NUMBER OF STORMS PER Sub-BASIN BY YEAR

PERCENTAGES OF STORMS PER sub_BASIN BY YEAR

NUMBER OF STORMS PER Sub_BASIN BY YEAR with WIND GREATER THAN 75 PERCENTILE(3rd QUALNTILE)

Row

Storm Visualization Per Sub_Basin

Sub-Basin: is a structural geologic feature where a larger basin is divided into a series of smaller basins with intervening intrabasinal highs.

Question 4: What is the distribution of storm per sub_basin ?

The distribution of storms happened in subbasin is much smaller than the ones in basin. Almost all the number is around 250, while MM has an extreme high number between 2014 to 2016 among others.

Question 5: Is there any difference from 2014 to 2017 per one specific sub_basin ?

When we look at the “percentage of number of storms”" chart, the proportion of each years in different basin diver a lot. The reason cause this could be the limitation of the geologic feature.

Question 6: Whether Hurricane has the same distribution as storm in all basin?

The chart presents the hurricane numbers in each subbasin is quite interesting. When we compare it with the one on the left of this line, we could find out that most of the storm happened in each basin could be considered as Hurricane. So we could get an conclusion that the subbasin is a geologic feature where hurricane usually happened.

YEAR WISE STORM DATA

Row

2014 STORM DATA

Row

2015 STORM DATA

Row

2016 STORM DATA

Row

2017 STORM DATA

MONTH WISE STORM DATA

Column

North America Basin Month wise plots

Eastern Pacific Basin Month wise plots

South West -Indian Ocean Month Wise plots

---
title: "ANLY 512 - Lab2"
author: "Yang Lu, Jiayi Zhang"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    storyboard: true
    source: embed
    vertical_layout: fill
---


```{r setup, include=FALSE}

#load package first
library(flexdashboard)
library(knitr)
library(ggplot2)
library(ggthemes)
library(quantmod)
library(plyr)
library(DT)
library(quantmod)
library(plyr)
library(DT)
library(dygraphs)
library(xts)
library(zoo)
library(dplyr)
require(dplyr)
library(scales)
library(lubridate)
library(plotly)
library(rnoaa)
library(ggmap)
library(widgetframe)
library(rbokeh)
library(maps)

#pull data
#STORM_2014 = storm_data(year='2014')
#STORM_2015 = storm_data(year='2015')
#STORM_2016 = storm_data(year='2016')
#STORM_2017 = storm_data(year='2017')

#quickly check data sturcture 
#structure(STORM_2014)

#choose variable for analysis
#STORM_2014_SUBSET = select(STORM_2014,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)

#STORM_2015_SUBSET = select(STORM_2015,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)

#STORM_2016_SUBSET = select(STORM_2016,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)

#STORM_2017_SUBSET = select(STORM_2017,serial_num,iso_time,season,num,basin,sub_basin,name,nature,latitude,longitude,wind.wmo.,pres.wmo.,center,	wind.wmo..percentile	,pres.wmo..percentile,track_type,latitude_for_mapping,longitude_for_mapping,	current.basin)

#STORM_DATA_2014_2017=rbind(STORM_2014_SUBSET,STORM_2015_SUBSET,STORM_2016_SUBSET,STORM_2017_SUBSET)

#STORM_DATA_2014_2017$season = factor(STORM_DATA_2014_2017$season)
#STORM_DATA_2014_2017$serial_num = factor(STORM_DATA_2014_2017$serial_num)
#STORM_DATA_2014_2017$name = factor(STORM_DATA_2014_2017$name)


#writing to csv so as not to download every time
#write.csv(STORM_DATA_2014_2017, file = 'STORM_DATA_2014_2017.csv')

# data screening and format set up
STORM_DATA_2010_2014 <- read.csv(file = 'STORM_DATA_2014_2017.csv', header = TRUE)
STORM_DATA_2010_2014$season = factor(STORM_DATA_2010_2014$season)
STORM_DATA_2010_2014$serial_num = factor(STORM_DATA_2010_2014$serial_num)
STORM_DATA_2010_2014$name = factor(STORM_DATA_2010_2014$name)

STORM_DATA_2010_2014$iso_time = as.Date(STORM_DATA_2010_2014$iso_time, format = "%Y-%m-%d")
STORM_DATA_2010_2014$iso_months = months(STORM_DATA_2010_2014$iso_time)
STORM_DATA_2010_2014$iso_month = month(STORM_DATA_2010_2014$iso_time)
STORM_DATA_2010_2014$iso_month = factor(STORM_DATA_2010_2014$iso_month)

STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!="-999",]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!=-1,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo.!=0,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$pres.wmo.!=-1,]
STORM_DATA_2010_2014 =STORM_DATA_2010_2014[STORM_DATA_2010_2014$pres.wmo.!=0,]
STORM_DATA_2010_2014$Basin_name = as.factor(paste(STORM_DATA_2010_2014$name, STORM_DATA_2010_2014$basin, sep = "."))

summary(STORM_DATA_2010_2014)

```
NUMBER OF STORMS BY BASIN
============================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------

### Storm Data Visualization  

What is storms?

Storms are created when a center of low pressure develops with the system of high pressure surrounding it. This combination of opposing forces can create winds and result in the formation of storm clouds such as cumulonimbus. Small localized areas of low pressure can form from hot air rising off hot ground, resulting in smaller disturbances such as dust devils and whirlwinds.

Storms VS Climate Change

No storm or heat wave can be directly attributed to climate change, but the warming world generally makes these weather events more common and more extreme.

Why We need to study storms?

Storms have the potential to harm lives and property via storm surge, heavy rain or snow causing flooding etc.To conduct this study, We downloaded data from 2014 to 2017 by rnoaa package from NCDC website. We will visualize storm occurence by number, by area and by year. This will give us an idea on how the storms are formed and how climate change contributs to it.

Row
-----------------------------------------------------------------------

### NUMBER OF STORMS PER BASIN BY YEAR

```{r}

STORM_DATA_2010_2014 %>%
  group_by(basin, season) %>% tally() %>%ggplot( aes(x=basin, y=n, fill=season)) + geom_bar(stat="identity",position="dodge")+ ggtitle("Number of storms by year per basin")+labs(x="basnin name",y="count of number of storms")


```

### PERCENTAGES OF STORMS PER BASIN BY YEAR

```{r}
STORM_DATA_2010_2014 %>%
  group_by(basin, season) %>% tally() %>%ggplot( aes(x=basin, y=n, fill=season)) + geom_bar(stat="identity",position="fill")+ ggtitle("Season")+labs(x="basnin name",y="percentage of number of storms by year")


```

### NUMBER OF STORMS PER BASIN BY YEAR with WIND GREATER THAN 75 PERCENTILE(3rd QUALNTILE)

```{r}


STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo..percentile>=75,] %>%
  group_by(basin, season) %>% tally() %>%ggplot( aes(x=basin, y=n, fill=season)) + geom_bar(stat="identity",position="dodge")+ ggtitle("Number of storms by year per basin")+labs(x="basnin name",y="count of number of storms")

```

Row
-----------------------------------------------------------------------
### Storm Visualization Per Basin  

Question 1: What is the distribution of storm per basin ?

As the first barchart shows, in general, 2014 is the year that has the most storm happened around all the basin. And the year of 2017 has the least of storms number (ignoring the missing data of EP,NA,NI)

If we take a look at the storm happened distribution, we will find the EP (east pacific basin) has the most storms happened in totall. On the contrary, NI(north indonesia basin) has the least number of storms. One more thing need to be mentioned, WP (west pacific basin) had the most amount of storms in 2015 which surpluses any year's storms number among all the basin.

Question 2: Is there any difference from 2014 to 2017 per one specific basin ?

As the second barchart shows, When considering the percentage of storm number in each basin, it is clearly that Year 2014 and 2016 occupited almost the same propotion in each basin, while year 2015's proportion is divered among different basins.SP (south pacific basin has the least and the west pacific basin has the most)

Question 3: whether Hurricane has the same distribution as storm in all basin?

TIPS: When wind speed is over 74 mph or faster, the storm could be considered as Hurricane. As meteorologists say campared with intense storm, hurricanes tend to stick around much longer, cover more ground and cause more damage. So it is also important to seperate hurricane charts in our study.

As it shows in the third graph, the hurricanes' distribution generally looks the same as storm's, and the total number is smaller than the storms'. The number of Hurricanes were not that high in both EP and SP basin as how storm's data look. We can concluded that even though there were a lot storms happened in 2014 a lot of them were not that severe.

Row
-----------------------------------------------------------------------

### NUMBER OF STORMS PER Sub-BASIN BY YEAR

```{r}

STORM_DATA_2010_2014 %>%
  group_by(sub_basin, season) %>% tally() %>%ggplot( aes(x=sub_basin, y=n, fill=season)) + geom_bar(stat="identity",position="dodge")+ ggtitle("Number of storms by year per Sub basin")+labs(x="Sub basnin name",y="count of number of storms")


```

### PERCENTAGES OF STORMS PER sub_BASIN BY YEAR

```{r}
STORM_DATA_2010_2014 %>%
  group_by(sub_basin, season) %>% tally() %>%ggplot( aes(x=sub_basin, y=n, fill=season)) + geom_bar(stat="identity",position="fill")+ ggtitle("Season")+labs(x="Sub basnin name",y="percentage of number of storms by year")

```

### NUMBER OF STORMS PER Sub_BASIN BY YEAR with WIND GREATER THAN 75 PERCENTILE(3rd QUALNTILE)

```{r}

STORM_DATA_2010_2014[STORM_DATA_2010_2014$wind.wmo..percentile>=75,] %>%
  group_by(sub_basin, season) %>% tally() %>%ggplot( aes(x=sub_basin, y=n, fill=season)) + geom_bar(stat="identity",position="dodge")+ ggtitle("Number of storms by year per basin")+labs(x="basnin name",y="count of number of storms")

```

Row
-----------------------------------------------------------------------
### Storm Visualization Per Sub_Basin  

Sub-Basin: is a structural geologic feature where a larger basin is divided into a series of smaller basins with intervening intrabasinal highs.

Question 4: What is the distribution of storm per sub_basin ?

The distribution of storms happened in subbasin is much smaller than the ones in basin. Almost all the number is around 250, while MM has an extreme high number between 2014 to 2016 among others. 

Question 5: Is there any difference from 2014 to 2017 per one specific sub_basin ?

When we look at the "percentage of number of storms"" chart, the proportion of each years in different basin diver a lot. The reason cause this could be the limitation of the geologic feature.

Question 6: Whether Hurricane has the same distribution as storm in all basin?

The chart presents the hurricane numbers in each subbasin is quite interesting. When we compare it with the one on the left of this line, we could find out that most of the storm happened in each basin could be considered as Hurricane. So we could get an conclusion that the subbasin is a geologic feature where hurricane usually happened.

YEAR WISE STORM DATA
===========================================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------

### Spatial Visualization

Question 7: Where is the center of storm from 2014 to 2017 ?

When we looking at the green mark disturibution, which stands for the wind movement, We find that most of the storm centers are located in EP, WP, NA basion, which is consistent with the bar chart in previous page. 

Question 8: Take the NA basin for example, what is the movement from 2014 to 2017 ?

The storms in NA basin become more active in these four years. At the same time the wind speed becomes more extreme, which also measn the weather in the NA basin become more inconstant in these yeas.

Row
-----------------------------------------------------------------------
### 2014 STORM DATA
```{r fig.width=9, fig.height=3, echo=FALSE}

 suppressWarnings(figure(width = 1200, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "gray") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2014',], size = 4, hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```

Row
-----------------------------------------------------------------------
### 2015 STORM DATA
```{r fig.width=9, fig.height=3, echo=FALSE}


 suppressWarnings(figure(width = 1200, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "gray") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2015',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```

Row
-----------------------------------------------------------------------

### 2016 STORM DATA
```{r fig.width=9, fig.height=3, echo=FALSE}


 suppressWarnings(figure(width = 1200, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "gray") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2016',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```

Row
-----------------------------------------------------------------------
### 2017 STORM DATA
```{r fig.width=9, fig.height=3, echo=FALSE}


 suppressWarnings(figure(width = 1200, height = 250, padding_factor = 0) %>%
  ly_map("world", col = "gray") %>%
  ly_points(longitude_for_mapping, latitude_for_mapping,color=wind.wmo..percentile, data = STORM_DATA_2010_2014[STORM_DATA_2010_2014$season=='2017',], size = 4,
            hover = c(basin)))

#widgetframe::frameWidget(plot,width=600,height=400)

```



MONTH WISE STORM DATA
===========================================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------

### Seasonal Analysis

It is very important to analysis the data by seasons, which will hlep us better trace the storms and prepare for the disaster managment ahead of time.In this part, We take a close look at NA, EP and SI basin area upon their monthly movement data. 

Question 9: How to identify the latitute and longitute of each basin ?

By looking at the x-axis and y-axis from previous movemen plot. 

NA--North America--xlim(-180, -20) + ylim(3, 80)

EP--Eastern Pacific regions--xlim(-110, -150) + ylim(10, 20)

SI--South West -Indian Ocean--xlim(40, 150) + ylim(-40, 5)


Question 10: What can we see by looking at the monthly storm data per basin ?

In general, July to October is the high-incident season for storms. And usually it takes storms three months to finish its generation loop. On the contrary, the South West Indian Ocean has a total different performance. Most of the stroms happened from January to April. Earth revolution could explain the difference. Still summer should be considered as the peak season of storm.

Column
-----------------------------------------------------------------------

### North America Basin Month wise plots
```{r fig.width=7, fig.height=8, echo=FALSE}
ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "gray25", colour = "gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(-180, -20) + ylim(3, 
    80) +  labs(x = "", y = "", colour = "Wind \n(knots)") + scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)

```


### Eastern Pacific Basin Month wise plots
```{r fig.width=7, fig.height=8, echo=FALSE}

ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "gray25", colour = "gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(-110, -150) + ylim(10, 
    20) +  labs(x = "", y = "", colour = "Wind \n(knots)") +scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)

```

### South West -Indian Ocean Month Wise plots
```{r fig.width=7, fig.height=8, echo=FALSE}

ggplot(STORM_DATA_2010_2014, aes(x = longitude_for_mapping, y = latitude_for_mapping, group = Basin_name)) + 
    geom_polygon(data = map_data("world"), aes(x = long, y = lat, group = group), 
        fill = "gray25", colour = "gray10", size = 0.2) + geom_path(data = STORM_DATA_2010_2014, 
    aes(group = Basin_name, colour = wind.wmo.), size = 2) + xlim(40, 150) + ylim(-40, 
    5) +  labs(x = "", y = "", colour = "Wind \n(knots)") +scale_color_gradient2(midpoint=70, low="white", mid="blue",
                     high="dark orange", space ="Lab" )+facet_wrap(~iso_months)

```