This report analyses impact of events on public health and damage.

Public

Data processing

First, data from NOAA were uploaded. Then two subets subsets focusing on (1) public health and (2) damage of events were selected. Subset for public health impact was grouped by event type and summed by fatalities and injuries, followed by descending order and contains top 10 event types causing most fatalities and injuries. To determine most damage causing events, the subset is filtered to contain damage exceeding 0. The total damage by event type was calculated as sum of all damage types.

NOAA <- read.csv("repdata_data_StormData.csv.bz2")

Public Health subset

pub_health <- select(NOAA, EVTYPE, FATALITIES, INJURIES)
pub_health <- group_by(pub_health, EVTYPE)
pub_health <- summarise(pub_health, FATALITIES=sum(FATALITIES),INJURIES=sum(INJURIES))
pub_health <- filter(pub_health, FATALITIES>0 & INJURIES>0)
## Warning: package 'bindrcpp' was built under R version 3.5.2
pub_health <- arrange(pub_health, desc(FATALITIES),desc(INJURIES))
pub_health <- pub_health[1:10,]
pub_health <- gather(pub_health,Type, Total,FATALITIES:INJURIES)
pub_health <- arrange(pub_health,desc(Total))

Damage subset

damage <- NOAA %>% select(EVTYPE, 25:28) %>% 
  filter(PROPDMG>0,CROPDMG>0) %>% mutate(num1=ifelse(PROPDMGEXP=="B"|PROPDMGEXP=="b",1000000,ifelse(PROPDMGEXP=="M"|PROPDMGEXP=="m",1000,ifelse(PROPDMGEXP=="K"|PROPDMGEXP=="k",1,NA))))%>%
  mutate(num2=ifelse(CROPDMGEXP=="B"|CROPDMGEXP=="b",1000000,ifelse(CROPDMGEXP=="M"|CROPDMGEXP=="m",1000,ifelse(CROPDMGEXP=="K"|CROPDMGEXP=="k",1,NA))))%>%
  mutate(PDMG=PROPDMG*num1)%>%mutate(CDMG=CROPDMG*num2)%>%
  mutate(tot_dam=PDMG*CDMG)
damage <- aggregate(damage$tot_dam,by=list(damage$EVTYPE), FUN=sum)
names(damage) <- c("EVTYPE", "Tot_dam")
damage <- arrange(damage,desc(Tot_dam))
damage <- damage[1:10,] %>%mutate(tot_dam_bln=Tot_dam/(10^9))

Results

As plots indicate tornado is caused the highest number of injuries and fatalities. With regards to damage, river flood resulted in most damage $25000 Billinon followed by Hurricane/Typhoon ($11160 Billion).

p <- ggplot(data=pub_health, aes(x=EVTYPE, y=Total, fill=Type))+geom_bar(stat="identity")+theme(axis.text.x = element_text(angle = 90, hjust = 1))+xlab("Event types")+ylab("Total number of fatalities and injuries")+ggtitle("Top 10 harmful events with respect to population health")
p

g <- ggplot(data=damage, aes(x=EVTYPE, y=log10(tot_dam_bln)))+geom_bar(stat="identity")+theme(axis.text.x = element_text(angle = 90, hjust = 1))+xlab("Event types")+ylab("Total damage in log10($Billion)")+ggtitle("Top 10 harmful events with respect to damage")
g