{r setup, include=FALSE} # knitr::opts_chunk$set(echo = TRUE) #

Synopsis

The goal of this study is explore the NOAA Storm Database and answer some basic questions about weather events in the US. The weather events cause various forms of damages to the communities. The purpose of this analysis is to provide the list of major cause of life disruption that the Municipalities and other high authorities can take proactive action to save lives and properties in the future.

For the study, the source data (https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2) is downloaded from the course website. The documentation (https://d396qusza40orc.cloudfront.net/repdata%2Fpeer2_doc%2Fpd01016005curr.pdf) is downloaded from National Weather Service

The main focus is to present the most harmful weather events that has greates impact on lives.

Settings

# loading libraries
library(plyr)
library(ggplot2)
library(knitr)
#Setting default working directory
setwd("C:\\DS\\Storm")

Accessing source data

#Loading and preprocessing weather data
dr<- read.csv('repdata_data_StormData.csv',header=TRUE)
weather_data <- dr[ with (dr, { !(is.na(EVTYPE)) } ), ]

#Checking first few rows of the dataset
head(weather_data)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL
## 2       1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL
## 4       1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL
##    EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO         0                                               0
## 2 TORNADO         0                                               0
## 3 TORNADO         0                                               0
## 4 TORNADO         0                                               0
## 5 TORNADO         0                                               0
## 6 TORNADO         0                                               0
##   COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1         NA         0                      14.0   100 3   0          0
## 2         NA         0                       2.0   150 2   0          0
## 3         NA         0                       0.1   123 2   0          0
## 4         NA         0                       0.0   100 2   0          0
## 5         NA         0                       0.0   150 2   0          0
## 6         NA         0                       1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15    25.0          K       0                                    
## 2        0     2.5          K       0                                    
## 3        2    25.0          K       0                                    
## 4        2     2.5          K       0                                    
## 5        2     2.5          K       0                                    
## 6        6     2.5          K       0                                    
##   LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1     3040      8812       3051       8806              1
## 2     3042      8755          0          0              2
## 3     3340      8742          0          0              3
## 4     3458      8626          0          0              4
## 5     3412      8642          0          0              5
## 6     3450      8748          0          0              6
#Checking row/column count of the dataset 
dim(weather_data)
## [1] 902297     37
#Checking the structure of the dataset
str(weather_data)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
##  $ BGN_TIME  : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
##  $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
##  $ STATE     : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : Factor w/ 35 levels "","  N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_LOCATI: Factor w/ 54429 levels "","- 1 N Albion",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_DATE  : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_TIME  : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ 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   : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_LOCATI: Factor w/ 34506 levels "","- .5 NNW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ 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: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ WFO       : Factor w/ 542 levels ""," CI","$AC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ ZONENAMES : Factor w/ 25112 levels "","                                                                                                               "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ 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   : Factor w/ 436774 levels "","-2 at Deer Park\n",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...

Analysis and Results

#scanning historical data 
weather_data$Year <- as.numeric(format(as.Date(weather_data$BGN_DATE, format = "%m/%d/%Y %H:%M:%S"), "%Y"))
n_row <- count(weather_data, 'Year')
t(n_row)
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## Year 1950 1951 1952 1953 1954 1955 1956 1957 1958  1959  1960  1961  1962
## freq  223  269  272  492  609 1413 1703 2184 2213  1813  1945  2246  2389
##      [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## Year  1963  1964  1965  1966  1967  1968  1969  1970  1971  1972  1973
## freq  1968  2348  2855  2388  2688  3312  2926  3215  3471  2168  4463
##      [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35]
## Year  1974  1975  1976  1977  1978  1979  1980  1981  1982  1983  1984
## freq  5386  4975  3768  3728  3657  4279  6146  4517  7132  8322  7335
##      [,36] [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46]
## Year  1985  1986  1987  1988  1989  1990  1991  1992  1993  1994  1995
## freq  7979  8726  7367  7257 10410 10946 12522 13534 12607 20631 27970
##      [,47] [,48] [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57]
## Year  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006
## freq 32270 28680 38128 31289 34471 34962 36293 39752 39363 39184 44034
##      [,58] [,59] [,60] [,61] [,62]
## Year  2007  2008  2009  2010  2011
## freq 43289 55663 45817 48161 62174
weather_data <- weather_data[weather_data$Year >= 1994, ]
dim(weather_data)
## [1] 702131     38
#show weather_data data results
head(weather_data)
##        STATE__          BGN_DATE BGN_TIME TIME_ZONE COUNTY
## 187560       1  1/6/1995 0:00:00     0300       CST      0
## 187561       1 1/22/1995 0:00:00     1800       CST      0
## 187562       1  2/9/1994 0:00:00     2200       CST      0
## 187563       1  2/6/1995 0:00:00     2100       CST      0
## 187565       1 2/11/1995 0:00:00     1300       CST      0
## 187566       1 10/4/1995 0:00:00     1200       CST      0
##                              COUNTYNAME STATE                    EVTYPE
## 187560   ALZ001 - 011 - 014 - 021 - 026    AL             FREEZING RAIN
## 187561         ALZ001 - 021 - 024 - 027    AL                      SNOW
## 187562                       ALZ001>007    AL     ICE STORM/FLASH FLOOD
## 187563 ALZ001>011 - 014 - 016>018 - 020    AL                  SNOW/ICE
## 187565                       ALZ001>029    AL                  SNOW/ICE
## 187566                       ALZ001>050    AL HURRICANE OPAL/HIGH WINDS
##        BGN_RANGE BGN_AZI    BGN_LOCATI          END_DATE END_TIME
## 187560         0                                          1000CST
## 187561         0                       1/23/1995 0:00:00  0800CST
## 187562         0                       2/10/1994 0:00:00  2300CST
## 187563         0                        2/8/1995 0:00:00  0500CST
## 187565         0         North Alabama 2/12/1995 0:00:00  0400CST
## 187566         0                       10/5/1995 0:00:00  1000CST
##        COUNTY_END COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH  F
## 187560          0         NA         0                         0     0 NA
## 187561          0         NA         0                         0     0 NA
## 187562          0         NA         0                         0     0 NA
## 187563          0         NA         0                         0     0 NA
## 187565          0         NA         0                         0     0 NA
## 187566          0         NA         0                         0     0 NA
##        MAG FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO
## 187560   0          0        0     0.0                  0               
## 187561   0          0        0     0.0                  0               
## 187562   0          0        2     0.0                  0               
## 187563   0          0        0     0.0                  0               
## 187565   0          0        0     0.0                  0               
## 187566   0          2        0     0.1          B      10          M    
##        STATEOFFIC
## 187560           
## 187561           
## 187562           
## 187563           
## 187565           
## 187566           
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ZONENAMES
## 187560                                                                                                                                                                                                                                                                                                                                                                                                                                                      LAUDERDALE - LAUDERDALE - MARION - WINSTON - CLEBURNE - ST. CLAIR
## 187561                                                                                                                                                                                                                                                                                                                                                                                                                                                             LAUDERDALE - LAUDERDALE - CLEBURNE - JEFFERSON - TALLADEGA
## 187562                                                                                                                                                                                                                                                                                                                                                                                                                                 LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN
## 187563                                                                                                                                                                                                                                                                                                                                         LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - WINSTON - CULLMAN - BLOUNT - ETOWAH - CHEROKEE
## 187565                                                                                                                                                                                                   LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CALHOUN - CHEROKEE - CLEBURNE - PICKENS - TUSCALOOSA - JEFFERSON - SHELBY - ST. CLAIR - TALLADEGA - CLAY - RANDOLPH
## 187566 LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CALHOUN - CHEROKEE - CLEBURNE - PICKENS - TUSCALOOSA - JEFFERSON - SHELBY - ST. CLAIR - TALLADEGA - CLAY - RANDOLPH - SUMTER - GREENE - HALE - PERRY - BIBB - CHILTON - COOSA - TALLAPOOSA - CHAMBERS - MARENGO - DALLAS - AUTAUGA - LOWNDES - ELMORE - MONTGOMERY - MACON - BULLOCK - LEE - RUSSELL - PIKE - BARBOUR
##        LATITUDE LONGITUDE LATITUDE_E LONGITUDE_
## 187560        0         0          0          0
## 187561        0         0          0          0
## 187562        0         0          0          0
## 187563        0         0          0          0
## 187565        0         0          0          0
## 187566        0         0          0          0
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        REMARKS
## 187560                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Light freezing rain coated bridges and overpasses across the northern third of Alabama during the early morning.  The icing on bridges and roadways was responsible for a number of traffic accidents.  Icing was apparently not severe enough to bring down trees or power lines.  The death of a 33-year-old man in a single-car accident in Limestone County was attributed to icy road conditions. 
## 187561                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Light snow fell across the northern third of Alabama, but thanks to relatively warm ground temperatures, little accumulation occurred and travel was not significantly affected.  Snow fell from about 1800 CST on January 22nd to 0300 CST on the 23rd across northwest and north-central Alabama and from 0300 CST to 0800 CST across northeast Alabama.  Heaviest snowfall with amounts of one to two inches were reported in Franklin, Lawrence, and eastern Colbert Counties in the northwest and in Marshall and Jackson Counties in the northeast.  Lauderdale, Limestone, Madison, Marion, Winston, Cullman, Morgan, Blount, Etowah, Dekalb, and northern Cherokee Counties reported varying amounts around an inch.  Lamar, Fayette, Walker, Jefferson, northern Shelby, Talladega, St. Clair, Calhoun, and northern and western Cleburne Counties had snow flurries with spotty locations reporting up to an inch.  Icing on bridges was spotty. 
## 187562                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       A devastating and paralyzing ice storm struck a seven county area of northwest Alabama.  The weight of the ice felled numerous trees blocking roads and making travel impossible.  Damage to homes and businesses was widespread.  Precipitation during the event ranged from three to  inches.  As the ice melted and drained into swollen streams, some roads in every county became covered with water due to flash flooding. 
## 187563                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Snow and ice combined to close roads across north-central and northeast Alabama Monday night into early Wednesday morning.  The hazardous driving conditions prompted schools to be closed in Etowah, Blount, Marshall, Cherokee, and DeKalb Counties.  Heaviest snow was located in a narrow band from near Florence across the state to Fort Payne.  While amounts were light, generally around one to two inches, icing contributed to numerous travel problems.  A car accident attributed to the conditions resulted in the death of a man, 25, near Athens, and another man was killed in an accident in Huntsville. 
## 187565                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      A winter storm brought a mixture of precipitation generally to the northern third of Alabama.  Snowfall amounts were generally in the one to two-inch range while icing was reported in many locations across northern Alabama as water froze mainly on bridges and overpasses.  A number of automobile accidents were attributed to the poor driving conditions. 
## 187566 Hurricane Opal moved ashore in the Florida Panhandle then moved north-northeast across the state of Alabama.  Damage was extensive and no county in the state was spared some effect of the storm.  Damage was the greatest in the eastern counties with damage decreasing from east-to-west across the state.   Damage also decreased as you went north in the state.  Damage varied  with many trees, signs, and power lines downed.  At the worst, 2.6 million people in Alabama were without electricity, some for over a week.  The center of the storm entered the state near the Covington/Escambia County line on the Florida border.  It moved north-northeast with the center moving just west of the city of Montgomery, near the City of Talladega, and near Fort Payne before exiting the state near the northeast tip. Primary damage came from strong wind which toppled trees and power lines and damaged signs.  Mobile homes were damage both by falling trees and by strong wind.  Wind speeds varied across the state.  The short table below indicates the highest reported gust recorded at the locations shown. ,,Wind,,Speed City,,Direction,,of Gust Birmingham,NE,,48 mph Huntsville,N,,55 mph Anniston,NE,,35 mph Tuscaloosa,NW,,46 mph Columbus, GA,SSE,,44 mph Montgomery    Dannelly Field,E,,63 mph    Maxwell Air     Force Base,SE,,90 mph Alabaster,Unavailable,49 mph Ozark,,SSE,,98 mph Dothan,SE,,69 mph Heavy rain also caused creeks and streams to swell to bankfull and beyond, however, there were very few reports of water flooding buildings.  Water damage occurred to structures in many locations where wind or falling trees damaged roofs.  Rainfall measurements made for a 24-hour period ending around 0700 CDT on October 5th included the following reports:\n\nTwo people were killed in Gadsden, Etowah County, when high wind toppled a massive oak tree onto their mobile home.  Several other people were killed in the state but those deaths such as house fires and asphyixiation were not directly attributable to the weather.  M35MH, F33MH Damage figures are estimates from information obtained from the American Red Cross, Alabama Emergency Management Agency, and newspaper articles. Additional information on Hurricane Opal can be found under the heading for Southwest Alabama prepared by the National Weather Service Office in Mobile and under Southeast Alabama prepared by the National Weather Service Office in Tallahassee, FL. 
##        REFNUM Year
## 187560 187560 1995
## 187561 187561 1995
## 187562 187562 1994
## 187563 187563 1995
## 187565 187565 1995
## 187566 187566 1995

Research Question 1

Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

As you can see in the chart below, Tornados are most harmful with respect to population health.

weather_data$harmful <- weather_data$FATALITIES + weather_data$INJURIES
head(weather_data)
##        STATE__          BGN_DATE BGN_TIME TIME_ZONE COUNTY
## 187560       1  1/6/1995 0:00:00     0300       CST      0
## 187561       1 1/22/1995 0:00:00     1800       CST      0
## 187562       1  2/9/1994 0:00:00     2200       CST      0
## 187563       1  2/6/1995 0:00:00     2100       CST      0
## 187565       1 2/11/1995 0:00:00     1300       CST      0
## 187566       1 10/4/1995 0:00:00     1200       CST      0
##                              COUNTYNAME STATE                    EVTYPE
## 187560   ALZ001 - 011 - 014 - 021 - 026    AL             FREEZING RAIN
## 187561         ALZ001 - 021 - 024 - 027    AL                      SNOW
## 187562                       ALZ001>007    AL     ICE STORM/FLASH FLOOD
## 187563 ALZ001>011 - 014 - 016>018 - 020    AL                  SNOW/ICE
## 187565                       ALZ001>029    AL                  SNOW/ICE
## 187566                       ALZ001>050    AL HURRICANE OPAL/HIGH WINDS
##        BGN_RANGE BGN_AZI    BGN_LOCATI          END_DATE END_TIME
## 187560         0                                          1000CST
## 187561         0                       1/23/1995 0:00:00  0800CST
## 187562         0                       2/10/1994 0:00:00  2300CST
## 187563         0                        2/8/1995 0:00:00  0500CST
## 187565         0         North Alabama 2/12/1995 0:00:00  0400CST
## 187566         0                       10/5/1995 0:00:00  1000CST
##        COUNTY_END COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH  F
## 187560          0         NA         0                         0     0 NA
## 187561          0         NA         0                         0     0 NA
## 187562          0         NA         0                         0     0 NA
## 187563          0         NA         0                         0     0 NA
## 187565          0         NA         0                         0     0 NA
## 187566          0         NA         0                         0     0 NA
##        MAG FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO
## 187560   0          0        0     0.0                  0               
## 187561   0          0        0     0.0                  0               
## 187562   0          0        2     0.0                  0               
## 187563   0          0        0     0.0                  0               
## 187565   0          0        0     0.0                  0               
## 187566   0          2        0     0.1          B      10          M    
##        STATEOFFIC
## 187560           
## 187561           
## 187562           
## 187563           
## 187565           
## 187566           
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ZONENAMES
## 187560                                                                                                                                                                                                                                                                                                                                                                                                                                                      LAUDERDALE - LAUDERDALE - MARION - WINSTON - CLEBURNE - ST. CLAIR
## 187561                                                                                                                                                                                                                                                                                                                                                                                                                                                             LAUDERDALE - LAUDERDALE - CLEBURNE - JEFFERSON - TALLADEGA
## 187562                                                                                                                                                                                                                                                                                                                                                                                                                                 LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN
## 187563                                                                                                                                                                                                                                                                                                                                         LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - WINSTON - CULLMAN - BLOUNT - ETOWAH - CHEROKEE
## 187565                                                                                                                                                                                                   LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CALHOUN - CHEROKEE - CLEBURNE - PICKENS - TUSCALOOSA - JEFFERSON - SHELBY - ST. CLAIR - TALLADEGA - CLAY - RANDOLPH
## 187566 LAUDERDALE - LAUDERDALE - COLBERT - FRANKLIN - LAWRENCE - LIMESTONE - MADISON - MORGAN - MARSHALL - JACKSON - DEKALB - MARION - LAMAR - FAYETTE - WINSTON - WALKER - CULLMAN - BLOUNT - ETOWAH - CALHOUN - CHEROKEE - CLEBURNE - PICKENS - TUSCALOOSA - JEFFERSON - SHELBY - ST. CLAIR - TALLADEGA - CLAY - RANDOLPH - SUMTER - GREENE - HALE - PERRY - BIBB - CHILTON - COOSA - TALLAPOOSA - CHAMBERS - MARENGO - DALLAS - AUTAUGA - LOWNDES - ELMORE - MONTGOMERY - MACON - BULLOCK - LEE - RUSSELL - PIKE - BARBOUR
##        LATITUDE LONGITUDE LATITUDE_E LONGITUDE_
## 187560        0         0          0          0
## 187561        0         0          0          0
## 187562        0         0          0          0
## 187563        0         0          0          0
## 187565        0         0          0          0
## 187566        0         0          0          0
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        REMARKS
## 187560                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Light freezing rain coated bridges and overpasses across the northern third of Alabama during the early morning.  The icing on bridges and roadways was responsible for a number of traffic accidents.  Icing was apparently not severe enough to bring down trees or power lines.  The death of a 33-year-old man in a single-car accident in Limestone County was attributed to icy road conditions. 
## 187561                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Light snow fell across the northern third of Alabama, but thanks to relatively warm ground temperatures, little accumulation occurred and travel was not significantly affected.  Snow fell from about 1800 CST on January 22nd to 0300 CST on the 23rd across northwest and north-central Alabama and from 0300 CST to 0800 CST across northeast Alabama.  Heaviest snowfall with amounts of one to two inches were reported in Franklin, Lawrence, and eastern Colbert Counties in the northwest and in Marshall and Jackson Counties in the northeast.  Lauderdale, Limestone, Madison, Marion, Winston, Cullman, Morgan, Blount, Etowah, Dekalb, and northern Cherokee Counties reported varying amounts around an inch.  Lamar, Fayette, Walker, Jefferson, northern Shelby, Talladega, St. Clair, Calhoun, and northern and western Cleburne Counties had snow flurries with spotty locations reporting up to an inch.  Icing on bridges was spotty. 
## 187562                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       A devastating and paralyzing ice storm struck a seven county area of northwest Alabama.  The weight of the ice felled numerous trees blocking roads and making travel impossible.  Damage to homes and businesses was widespread.  Precipitation during the event ranged from three to  inches.  As the ice melted and drained into swollen streams, some roads in every county became covered with water due to flash flooding. 
## 187563                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             Snow and ice combined to close roads across north-central and northeast Alabama Monday night into early Wednesday morning.  The hazardous driving conditions prompted schools to be closed in Etowah, Blount, Marshall, Cherokee, and DeKalb Counties.  Heaviest snow was located in a narrow band from near Florence across the state to Fort Payne.  While amounts were light, generally around one to two inches, icing contributed to numerous travel problems.  A car accident attributed to the conditions resulted in the death of a man, 25, near Athens, and another man was killed in an accident in Huntsville. 
## 187565                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      A winter storm brought a mixture of precipitation generally to the northern third of Alabama.  Snowfall amounts were generally in the one to two-inch range while icing was reported in many locations across northern Alabama as water froze mainly on bridges and overpasses.  A number of automobile accidents were attributed to the poor driving conditions. 
## 187566 Hurricane Opal moved ashore in the Florida Panhandle then moved north-northeast across the state of Alabama.  Damage was extensive and no county in the state was spared some effect of the storm.  Damage was the greatest in the eastern counties with damage decreasing from east-to-west across the state.   Damage also decreased as you went north in the state.  Damage varied  with many trees, signs, and power lines downed.  At the worst, 2.6 million people in Alabama were without electricity, some for over a week.  The center of the storm entered the state near the Covington/Escambia County line on the Florida border.  It moved north-northeast with the center moving just west of the city of Montgomery, near the City of Talladega, and near Fort Payne before exiting the state near the northeast tip. Primary damage came from strong wind which toppled trees and power lines and damaged signs.  Mobile homes were damage both by falling trees and by strong wind.  Wind speeds varied across the state.  The short table below indicates the highest reported gust recorded at the locations shown. ,,Wind,,Speed City,,Direction,,of Gust Birmingham,NE,,48 mph Huntsville,N,,55 mph Anniston,NE,,35 mph Tuscaloosa,NW,,46 mph Columbus, GA,SSE,,44 mph Montgomery    Dannelly Field,E,,63 mph    Maxwell Air     Force Base,SE,,90 mph Alabaster,Unavailable,49 mph Ozark,,SSE,,98 mph Dothan,SE,,69 mph Heavy rain also caused creeks and streams to swell to bankfull and beyond, however, there were very few reports of water flooding buildings.  Water damage occurred to structures in many locations where wind or falling trees damaged roofs.  Rainfall measurements made for a 24-hour period ending around 0700 CDT on October 5th included the following reports:\n\nTwo people were killed in Gadsden, Etowah County, when high wind toppled a massive oak tree onto their mobile home.  Several other people were killed in the state but those deaths such as house fires and asphyixiation were not directly attributable to the weather.  M35MH, F33MH Damage figures are estimates from information obtained from the American Red Cross, Alabama Emergency Management Agency, and newspaper articles. Additional information on Hurricane Opal can be found under the heading for Southwest Alabama prepared by the National Weather Service Office in Mobile and under Southeast Alabama prepared by the National Weather Service Office in Tallahassee, FL. 
##        REFNUM Year harmful
## 187560 187560 1995       0
## 187561 187561 1995       0
## 187562 187562 1994       2
## 187563 187563 1995       0
## 187565 187565 1995       0
## 187566 187566 1995       2
weather_data2 <- aggregate(harmful ~ EVTYPE, data=weather_data, FUN = sum)
weather_data_sorted <- weather_data2[order(-weather_data2$harmful), ]

#show weather_data data results
head(weather_data$harmful)
## [1] 0 0 2 0 0 2
health_harm_chart <- ggplot(data=head(weather_data_sorted,20), aes(x=reorder(EVTYPE, -harmful), y=harmful)) +
    geom_bar(fill="red",stat="identity")  + 
    ylab("Total number of injuries and/or fatalities") + xlab("Event type") +
    ggtitle("Question 1, Harmful impact of weather events in the US") +
    theme(legend.position="none")+
    theme(axis.text.x = element_text(angle = 90, size=9))

health_harm_chart

Research Question 2

Across the United States, which types of events have the greatest economic consequences?

As part of analysis, the following two datasets are created: a) for property damage and b) for crop damage

ds_crop_damage <- subset(weather_data, select=c(EVTYPE, CROPDMG, CROPDMGEXP))
ds_property_damage <- subset(weather_data, select=c(EVTYPE, PROPDMG, PROPDMGEXP))


UnitConv <- function(cnv) {
    if (toupper(cnv) =="H")
        return(100)
    else if (toupper(cnv) =="K")
        return(1000)
    else if (toupper(cnv) =="M")
        return(1000000)
    else if (toupper(cnv) =="B")
        return(1000000000)
    else if (!is.na(as.numeric(cnv))) 
        return(as.numeric(cnv))
    else if (cnv %in% c("", "-", "?", "+"))
        return(0)
    else {
        stop("Invalid value.")
    }
}


ds_property_damage$cnv <- sapply(ds_property_damage$PROPDMGEXP, FUN=UnitConv)
ds_property_damage$damage <- ds_property_damage$PROPDMG * ds_property_damage$cnv
ds_crop_damage$cnv <- sapply(ds_crop_damage$CROPDMGEXP, FUN=UnitConv)
ds_crop_damage$damage <- ds_crop_damage$CROPDMG * ds_crop_damage$cnv


property_damage <- aggregate(damage ~ EVTYPE, data=ds_property_damage, FUN = sum)
crop_damage <- aggregate(damage ~ EVTYPE, data=ds_crop_damage, FUN=sum)

prop_sorted <- property_damage[order(-property_damage$damage), ]
crop_sorted <- crop_damage[order(-crop_damage$damage), ]

Question 2(a). As you can see in the chart below, the events creating greatest property damage is Flood

#Show prop_sorted data
head(prop_sorted)
##                EVTYPE       damage
## 160             FLOOD 144179608807
## 386 HURRICANE/TYPHOON  69305840000
## 624       STORM SURGE  43193536000
## 785           TORNADO  25620370125
## 145       FLASH FLOOD  15716395994
## 230              HAIL  15335045704
#Creating property damage chart
propchart <- ggplot(data=head(prop_sorted,20), aes(x=reorder(EVTYPE, -damage), y=damage/1000000000)) +
   geom_bar(fill="red",stat="identity")  + 
    ylab("Total property damage (in Billions)") + xlab("Event Type") +
    ggtitle("Greatest Economic Consequences-Property Damage") +
    theme(legend.position="none")+
    theme(axis.text.x = element_text(angle = 90, size=9))
propchart

Question 2(b). As you can see in the chart below, the events creating greatest crop damage is Drought

#Show crop_sorted data
head(crop_sorted)
##                EVTYPE      damage
## 90            DROUGHT 13922066000
## 160             FLOOD  5506942450
## 401         ICE STORM  5022113500
## 230              HAIL  2982699163
## 378         HURRICANE  2741410000
## 386 HURRICANE/TYPHOON  2607872800
#Creating crop plot
cropchart <- ggplot(data=head(crop_sorted,20), aes(x=reorder(EVTYPE, -damage), y=damage/1000000000)) +
   geom_bar(fill="navyblue",stat="identity")  + 
    ylab("Total crop damage (in Billions)") + xlab("Event Type") +
    ggtitle("Greatest Economic consequences-Crop Damage") +
    theme(legend.position="none")+
    theme(axis.text.x = element_text(angle = 90, size=9))
cropchart

Conclusion and Summary

As you can observe from the three charts above, Tornados are most harmful with respect to population health. The events creating greatest property damage is found to be Flood and the events creating greatest crop damage is Drought.