In this report, the population health and economic impacts of weather events are analyzed using data obtained from the NOAA Storm Database. Fatalities and injuries by weather event type are used to describe population health, while property damage and crop damage are used to describe economic impacts. The total number of each of these 4 variables are aggregated by weather event type, and then sorted from highest to lowest. Tornadoes are responsible for the most fatalities and injuries, while floods and droughts are responsible for the most property and crop damage, respectively.

Loading the Raw Data

This section of code loads the raw data, and displays a summary of the data structure. The variables of interest for population health are FATALITIES and INJURIES, while the variables for economic impacts are PROPDMG, PROPDMGEXP, CROPDMG, and CROPDMGEXP.

storm_data<-read.csv("repdata_data_StormData.csv.bz2")
str(storm_data)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : chr  "4/18/1950 0:00:00" "4/18/1950 0:00:00" "2/20/1951 0:00:00" "6/8/1951 0:00:00" ...
##  $ BGN_TIME  : chr  "0130" "0145" "1600" "0900" ...
##  $ TIME_ZONE : chr  "CST" "CST" "CST" "CST" ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: chr  "MOBILE" "BALDWIN" "FAYETTE" "MADISON" ...
##  $ STATE     : chr  "AL" "AL" "AL" "AL" ...
##  $ EVTYPE    : chr  "TORNADO" "TORNADO" "TORNADO" "TORNADO" ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : chr  "" "" "" "" ...
##  $ BGN_LOCATI: chr  "" "" "" "" ...
##  $ END_DATE  : chr  "" "" "" "" ...
##  $ END_TIME  : chr  "" "" "" "" ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : chr  "" "" "" "" ...
##  $ END_LOCATI: chr  "" "" "" "" ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: chr  "K" "K" "K" "K" ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: chr  "" "" "" "" ...
##  $ WFO       : chr  "" "" "" "" ...
##  $ STATEOFFIC: chr  "" "" "" "" ...
##  $ ZONENAMES : chr  "" "" "" "" ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : chr  "" "" "" "" ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

Data Processing

Scale crop/property damage dollar amounts

Crop Damage

Dollar amounts for crop damage (CROPDMG) are converted to equivalent scale using the “magnitude” (CROPDMGEXP), which specifies whether the number in CROPDMG is thousands (K), millions (M), or billions (B). If the CROPDMGEXP is anything other than K, M, or B, it is considered a typo and set to zero.

crop_damage <- rep(0,length(storm_data$CROPDMG))

#thousands
k_indices <- storm_data$CROPDMGEXP == "K" | storm_data$CROPDMGEXP == "k"
crop_damage[k_indices] <- storm_data$CROPDMG[k_indices] * 1E3

#millions
m_indices <- storm_data$CROPDMGEXP == "M" | storm_data$CROPDMGEXP == "m"
crop_damage[m_indices] <- storm_data$CROPDMG[m_indices] * 1E6

#billions
b_indices <- storm_data$CROPDMGEXP == "B" | storm_data$CROPDMGEXP == "b"
crop_damage[b_indices] <- storm_data$CROPDMG[b_indices] * 1E9

#add column to storm_data with converted values
storm_data$CROPDMG_SCALED <- crop_damage

Property Damage

Similar to crop damage, dollar amounts for property damage (PROPDMG) are converted to equivalent scale using the “magnitude” (PROPDMGEXP). If the PROPDMGEXP is anything other than K, M, or B, it is considered a typo and set to zero.

prop_damage <- rep(0,length(storm_data$PROPDMG))

#thousands
k_indices <- storm_data$PROPDMGEXP == "K" | storm_data$PROPDMGEXP == "k"
prop_damage[k_indices] <- storm_data$PROPDMG[k_indices] * 1E3

#millions
m_indices <- storm_data$PROPDMGEXP == "M" | storm_data$PROPDMGEXP == "m"
prop_damage[m_indices] <- storm_data$PROPDMG[m_indices] * 1E6

#billions
b_indices <- storm_data$PROPDMGEXP == "B" | storm_data$PROPDMGEXP == "b"
prop_damage[b_indices] <- storm_data$PROPDMG[b_indices] * 1E9

#add column to storm_data with converted values
storm_data$PROPDMG_SCALED <- prop_damage

Aggregate and order data

Dataframes are created to aggregate data by population heath or economic outcomes. The dataframes are then sorted in order of highest to lowest.

Population health

Fatalities and injuries are aggregated and sorted.

fatal_by_evtype <- aggregate(FATALITIES ~ EVTYPE,data = storm_data,sum)
fatal_by_evtype <- fatal_by_evtype[order(-fatal_by_evtype$FATALITIES),]
inj_by_evtype <- aggregate(INJURIES ~ EVTYPE,data = storm_data,sum)
inj_by_evtype <- inj_by_evtype[order(-inj_by_evtype$INJURIES),]

Crop/property damage

Crop damage and property damage are aggregated and sorted.

cropdam_by_evtype <- aggregate(CROPDMG_SCALED ~ EVTYPE,data = storm_data,sum)
cropdam_by_evtype <- cropdam_by_evtype[order(-cropdam_by_evtype$CROPDMG_SCALED),]
propdam_by_evtype <- aggregate(PROPDMG_SCALED ~ EVTYPE,data = storm_data,sum)
propdam_by_evtype <- propdam_by_evtype[order(-propdam_by_evtype$PROPDMG_SCALED),]

Results

Which types of events are most harmful with respect to population health?

Create a bar plot with the top 10 events for fatalities and injuries. Tornadoes are the weather event type with most fatalities and injuries.

#par(mar = c(10,5,2,2),mfrow = c(2,1))
par(mfrow = c(1,2),mar = c(10,5,1,1), oma = c(0,0,2,0))
barplot(fatal_by_evtype$FATALITIES[1:10]/1000,names.arg = fatal_by_evtype$EVTYPE[1:10],las = 2, main = "Fatalities",ylab = "Number (Thousands)")
barplot(inj_by_evtype$INJURIES[1:10]/1000,names.arg = inj_by_evtype$EVTYPE[1:10],las = 2, main = "Injuries",ylab = "Number (Thousands)")
mtext("Top 10 Weather Events for Fatalities and Injuries",outer =TRUE)
Figure 1. Weather events with highest fatality and injury counts

Figure 1. Weather events with highest fatality and injury counts

Which types of events have the greatest economic consequences?

Create a bar plot with the top 10 events for property and crop damages. Floods cause the most propert damage, while droughts cause the most crop damage.

par(mfrow = c(1,2),mar = c(11,5,2,2), oma = c(0,0,2,0))
barplot(propdam_by_evtype$PROPDMG_SCALED[1:10]/1E9,names.arg = propdam_by_evtype$EVTYPE[1:10],las = 2, main = "Property Damage",ylab = "Total USD (Billions)")
barplot(cropdam_by_evtype$CROPDMG_SCALED[1:10]/1E9,names.arg = cropdam_by_evtype$EVTYPE[1:10],las = 2, main = "Crop Damage",ylab = "Total USD (Billions)")
mtext("Top 10 Weather Events Greatest Economic Concequences",outer =TRUE)
Figure 2. Weather events with highest most property and crop damages

Figure 2. Weather events with highest most property and crop damages