title: “NOAA Storm Data Analysis” author: “GIRIDHAR PAI” output: html_document ———————
This project analyzes storm data to find which weather events cause the most harm to people and the most economic damage. Tornadoes cause the most injuries and deaths, while floods and hurricanes cause the most financial damage.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Download data
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url, "stormdata.csv.bz2")
# Read data
data <- read.csv("stormdata.csv.bz2")
# Select needed columns
data2 <- data %>%
select(EVTYPE, FATALITIES, INJURIES, PROPDMG, CROPDMG)
# Create new columns
data2$Health <- data2$FATALITIES + data2$INJURIES
data2$Economic <- data2$PROPDMG + data2$CROPDMG
health <- data2 %>%
group_by(EVTYPE) %>%
summarise(total = sum(Health)) %>%
arrange(desc(total)) %>%
head(10)
barplot(health$total, names.arg = health$EVTYPE, las=2,
main="Top Harmful Events", ylab="Health Impact")
econ <- data2 %>%
group_by(EVTYPE) %>%
summarise(total = sum(Economic)) %>%
arrange(desc(total)) %>%
head(10)
barplot(econ$total, names.arg = econ$EVTYPE, las=2,
main="Top Economic Damage", ylab="Damage")