In this report, we present an analysis of the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. We particularly are interested in two major consequences of such events: - Public health related impacts which are reported as the number of fatalities and injuries in this dataset, - Economic impacts such as property and crop damages.
The downloaded data file is accessed from the current directory. The data file is extracted using bzfile method, and then it is read as a data frame using read.csv function.
Then, a new data fram called StormDF is created bt extractin the required columns from the main data set. In the next step, we create a summary of the StormDF such as for each EVTYPE, the summation of injuries , fatalities, and property and crop damages are reported.
library(plyr)
DF <- read.csv(bzfile("repdata-data-StormData.csv.bz2") , header = TRUE , sep = ",")
StormDF <- DF[, c("EVTYPE" , "FATALITIES" , "INJURIES" , "PROPDMG" , "PROPDMGEXP" , "CROPDMG" , "CROPDMGEXP")]
#Create a summary of the StormDF, which shows the total number of injuries, fatalities, total property and crop damage per EVTYPE
stormSum <- ddply(StormDF, ~EVTYPE, summarise, FATALITIES = sum(FATALITIES),
INJURIES = sum(INJURIES), PROPDMG = sum(PROPDMG), CROPDMG = sum(CROPDMG))
To answer this question, we demostarte the amount of injuries and fatalities for each event type in a plot. To do so, we choose 20 events with most number of ijuries and/or fatalities.
Injuries <- stormSum[order(stormSum$INJURIES, decreasing = T), c("EVTYPE",
"INJURIES")][1:20, ]
Fatalities <- stormSum[order(stormSum$FATALITIES, decreasing = T), c("EVTYPE",
"FATALITIES")][1:20, ]
par(mfrow = c(1, 2)) ; par(oma = c(0, 0, 2, 0))
barplot(Fatalities$FATALITIES , main = "Fatalities" , ylab= "Fatalities" , names.arg = Fatalities$EVTYPE ,
cex.axis = 0.8 ,cex.names = 0.7 , , las = 2)
barplot(Injuries$INJURIES , main = "Injuries" , ylab= "Injuries" , names.arg = Injuries$EVTYPE ,
cex.axis = 0.8 ,cex.names = 0.7 , , las = 2)
title("Health Related Implacts of the extreme weather events" ,outer = TRUE)
2.Across the United States, which types of events have the greatest economic consequences?
To answer this question, we present the amount of property and crop damage per each event type. As before, we choose 20 events with highest impact to compare.
PROPDAMG <- stormSum[order(stormSum$PROPDMG, decreasing = T), c("EVTYPE",
"PROPDMG")][1:20, ]
CROPDAMG <- stormSum[order(stormSum$CROPDMG, decreasing = T), c("EVTYPE",
"CROPDMG")][1:20, ]
par(mfrow = c(1, 2))
par(oma = c(0, 0, 2, 0))
barplot(PROPDAMG$PROPDMG/1e3 , main = "Property Damage" , ylab= "property damage(1e+3)" , names.arg = PROPDAMG$EVTYPE ,
cex.axis = 0.8 ,cex.names = 0.7 , las = 2)
barplot(CROPDAMG$CROPDMG , main = "Crop Damage" , ylab= "crop damage" , names.arg = CROPDAMG$EVTYPE ,
cex.axis = 0.8 ,cex.names = 0.7 , las = 2)
title("Economy Related Implacts of the extreme weather events" ,outer = TRUE)