Synopsis

In this project, the storm database taken from the U.S. National Oceanic and Atmospheric Administration (NOAA) has been analyzed, including the fatalities, injuries, property damage, and crop damage for each type of event. The project is mainly to determine which event is most harmful to US population (health) and which event has the largest economic consequences. The results show that Tornado is the most harmful event in respect to the US health (population). Based on the Property and Cost damage, we conclude that Hurricane/typhoon has the greatest economic consequences to the US.

Data processing

df <- read.csv("repdata_data_StormData.csv.bz2", header = TRUE, sep = ",")
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,
## : EOF within quoted string

The current downloaded data format is messy after around row number 546000. Therefore, only 546000 rows are included in the analysis. This may cause different results.

df_sub <- df[1:546000,c("EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP")]
df_sub[,c("FATALITIES","INJURIES","PROPDMG","CROPDMG")] <- sapply(df_sub[,c("FATALITIES","INJURIES","PROPDMG","CROPDMG")],as.numeric)

df_sub$PROPDMGEXP <- toupper(df_sub$PROPDMGEXP)
df_sub$CROPDMGEXP <- toupper(df_sub$CROPDMGEXP)

df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "")] <- 10^0
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "?")] <- 10^0
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "0")] <- 10^0
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "2")] <- 10^2
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "K")] <- 10^3
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "M")] <- 10^6
df_sub$CROPDMGFACTOR[(df_sub$CROPDMGEXP == "B")] <- 10^9

df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "")] <- 10^0
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "-")] <- 10^0
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "?")] <- 10^0
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "+")] <- 10^0
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "0")] <- 10^0
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "1")] <- 10^1
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "2")] <- 10^2
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "3")] <- 10^3
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "4")] <- 10^4
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "5")] <- 10^5
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "6")] <- 10^6
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "7")] <- 10^7
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "8")] <- 10^8
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "H")] <- 10^2
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "K")] <- 10^3
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "M")] <- 10^6
df_sub$PROPDMGFACTOR[(df_sub$PROPDMGEXP == "B")] <- 10^9

Results

healthImpact <- aggregate(x = list(HEALTH_IMPACT = df_sub$FATALITIES + df_sub$INJURIES), 
                          by = list(EVENT_TYPE = df_sub$EVTYPE), 
                          FUN = sum,
                          na.rm = TRUE)
healthImpact <- healthImpact[order(healthImpact$HEALTH_IMPACT, decreasing = TRUE),]

damageCostImpact <- aggregate(x = list(DAMAGE_IMPACT = df_sub$PROPDMGFACTOR + df_sub$CROPDMGFACTOR), 
                                  by = list(EVENT_TYPE = df_sub$EVTYPE), 
                                  FUN = sum,
                                  na.rm = TRUE)
damageCostImpact <- damageCostImpact[order(damageCostImpact$DAMAGE_IMPACT, decreasing = TRUE),]

The analysis results have been saved in healthImpact and damageCostImpact, which can be used to plot the bar charts.

barplot(healthImpact[1:10,]$HEALTH_IMPACT,names.arg = healthImpact[1:10,]$EVENT_TYPE)

barplot(damageCostImpact[1:10,]$DAMAGE_IMPACT,names.arg = damageCostImpact[1:10,]$EVENT_TYPE)

Conclusion

The conclusions can be given as follow: