According to the analysis, Tornado shows the most harmful effect on both economy and public health.
Please note I use R.utils to unzip bz2 file to speed up the process.
This code will save you the data on “RFile” folder in D drive.
setwd("D:\\")
if(!file.exists("Rfile")){
dir.create("Rfile")}
url <- "https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2"
download.file(url, destfile = "./Rfile/StormData.csv.bz2")
bunzip2("./Rfile/StormData.csv.bz2", "./Rfile/StormData.csv", remove = FALSE, skip = TRUE)
## [1] "./Rfile/StormData.csv"
## attr(,"temporary")
## [1] FALSE
Storm <- read.csv("./Rfile/StormData.csv")
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
S <- Storm %>%
select(c(EVTYPE, FATALITIES, INJURIES)) %>%
mutate(health = FATALITIES + INJURIES) %>%
select(c(EVTYPE, health)) %>%
ddply("EVTYPE", summarise, health = sum(health)) %>%
arrange(desc(health))
## Warning: failed to assign NativeSymbolInfo for env since env is already
## defined in the 'lazyeval' namespace
S1 <- Storm %>%
select(c(EVTYPE, PROPDMG, CROPDMG)) %>%
mutate(Econ = PROPDMG + CROPDMG) %>%
select(c(EVTYPE, Econ)) %>%
ddply("EVTYPE", summarise, Economic = sum(Econ)) %>%
arrange(desc(Economic))