---
title: "Tornadoes dashboard"
Author: "Xiaoxiao Lu, Ling Zhu"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
---
```{r}
library(plotly)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(plot3D)
library(reshape2)
```
```{r setup, include=FALSE}
data <- read.csv("C:/Users/xiaox/OneDrive/Documents/HU/512-visualization/lab2/1950-2021_all_tornadoes.csv")
data <- subset(data, data$yr >= 2000)
```
Yearly Accumulated Tornadoes Chart{data-orientation=columns}
==========================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Accumulated number of tornadoes every year
Data Source: https://www.spc.noaa.gov/wcm/#data
Q1. Which year has the most number of tornadoes?
Conclusions:
We take an overview of the number of tornadoes by counting the number of tornadoes in the range between 2000 and 2021. The year 2004 has the highest number of tornadoes, the following are 2011, 2008, 2019, and 2017(top 5). We find out that during the accumulation, the year 2011 has the steepest slope compared to the others. In March (Mar - April), the number of tornadoes increase from 158 to 975, increasing by 5.17 times. In April (April - May), the number of tornadoes increases to 1312, increasing by 34.56% month over month. According to the graphs and the increasing tendency of the number of tornadoes, we find that 2011 is a super outbreak of tornadoes, especially in March, and April.
Column {data-width=400}
------------------------------------------------------------------------------
### Yearly Accumulated Tornadoes Chart
```{r}
data_new <- data %>%
group_by(data$yr, data$mo) %>%
summarise(total_count = n(),
.groups = 'drop')
data_new <- data_new %>%
group_by(data_new$`data$yr`) %>%
mutate(total_count = cumsum(total_count))
p <- ggplot(data_new, aes(
x = factor(data_new$`data$mo`),
y = data_new$total_count,
group = factor(data_new$`data$yr`),
colour = factor(data_new$`data$yr`),
text = paste(
'Year: ', data_new$`data$yr`,
'<br>Month: ', data_new$`data$mo`,
'<br>Number of Tornadoes: ', data_new$total_count))) +
geom_line() +
geom_point() +
labs(
title = "Yearly Accumulated Tornadoes Chart",
x = "Month",
y = "Number of Tornadoes",
colour = "Year") +
theme_bw()
ggplotly(p, tooltip = c("text"))
```
Monthly Tornadoes Chart {data-orientation=columns}
==========================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Number of tornadoes of each month
Q2. Which month has the most number of Tornadoes?
Conclusions:
We can conclude that May is the most frequent month when tornadoes took place. During the year 2000 and 2021, there are 6148 tornadoes in total that happened in May. The following months are April(4388), June(4154), July(2324), and March(1940), which are the top 5 months in the number of tornadoes.
Column {data-width=400}
-----------------------------------------------------------------------
### Monthly Tornadoes Chart
```{r}
data$mo <- month.abb[data$mo]
brewed_spectral = rev(brewer.pal(10,'Spectral'))
monthly_data <- data %>%
group_by(data$mo) %>%
summarise(total_count=n(),
.groups = 'drop')
p.rank.countries <-
ggplot(data = monthly_data, aes(x = reorder(monthly_data$`data$mo`,monthly_data$total_count), y = monthly_data$total_count, text = paste('Month: ', monthly_data$`data$mo`, '<br>Number of Tornadoes: ', monthly_data$total_count))) +
geom_histogram(aes(fill = monthly_data$total_count), stat='identity', width=.75) +
ggtitle('Number of Tornadoes of Each Month') +
scale_fill_gradientn(name='Number of Tornadoes',colours=brewed_spectral) +
coord_flip() +
labs(x = "Month", y = "Number of Tornadoes") +
theme(axis.text = element_text(size = 7))
ggplotly(p.rank.countries, tooltip = c("text"))
```
State Tornadoes Map {data-orientation=columns}
==========================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Number of tornadoes and tornadoes losses of each state
Q3.1. Which state has the most amount of tornadoes?
Q3.2. Which state has the most losses?
Conclusions:
We can tell from the state tornadoes amount map, Texas has the most number of tornadoes (2848). The following states are Kansas (1972), Oklahoma (1446), Alabama (1369), and Mississippi (1329), these states are the top 5 states which have the most number of tornadoes from 2000 to 2021.
From the state tornado losses ($) map, we can tell that Texas has the most losses compared to the other states (2.11B). The rest states are Tennessee (1.68B), Ohio (617.98M), Louisiana (318.92M), and Arkansas (380.45M), these are the top 5 states which have the most losses from 2000 to 2021.
Column {data-width=400}
------------------------------------------------------------------------------
### State Tornadoes Amount Map
```{r}
state_data <- data %>%
group_by(data$st) %>%
summarise(total_count=n(),
.groups = 'drop')
g <- list(
scope = 'usa',
projection = list(type = 'albers usa')
)
plot_geo() %>%
add_trace(
z = state_data$total_count,
span = I(0),
locations = state_data$`data$st`,
locationmode = 'USA-states',
color = state_data$total_count,
colors = 'YlOrRd') %>%
layout(
title = "State Tornadoes Amount Map",
geo = g)
```
Column {data-width=400}
------------------------------------------------------------------------------
### State Tornadoes Losses Map
```{r}
state_data <- data %>%
group_by(data$st) %>%
summarise(total_count = sum(loss),
.groups = 'drop')
g <- list(
scope = 'usa',
projection = list(type = 'albers usa')
)
plot_geo() %>%
add_trace(
z = state_data$total_count,
span = I(0),
locations = state_data$`data$st`,
locationmode = 'USA-states',
color = state_data$total_count,
colors = 'YlOrRd') %>%
layout(
title = "State Tornadoes Losses Map",
geo = g)
```
Time-Series State Tornadoes Map {data-orientation=columns}
==========================================================================
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Number of tornadoes of each state every year
Q4. Where in the U.S. has the most active tornadoes?
Conclusions:
By playing the time-series mapping of tornadoes, we could find that Texas, Alabama, Mississippi, Florida, Illinois, Iowa, Tennessee, Georgia and Kentucky, Nebraska, Louisiana and Missouri, and Colorado are the worst states for tornadoes.
One thing that can stand out from the state's tornado map is that the highest averages are found in the Central and Southern Plains.
Column {data-width=400}
------------------------------------------------------------------------------
### Time-Series State Tornadoes Map
```{r}
g <- list(
scope = 'usa',
projection = list(type = 'albers usa')
)
plot_geo() %>%
add_markers(
x = ~data$slon,
y = ~data$slat,
color = data$st,
frame = data$yr,
alpha = 0.8) %>%
layout(geo = g)
```