Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern. This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.
The data was downloaded from the the course website, and stored in a local file. Using read.table, and marking separater as a comma, and headers equal to true the data was neatly read in.
setwd("C:/Users/Mike/Desktop/R_programming_2/Reproducible_research")
STORM<-read.table("repdata%2Fdata%2FStormData.csv.bz2", sep = ",", header = TRUE)
head(STORM)
## 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
str(STORM)
## '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/ 436781 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 ...
The data has two fields that effect health, Fatalities and injuries. To make this a little easier on the eyes, we will only look at the top 10 factors for each.
#Health ISSUES
library(plyr)
EvenTYPES <-ddply(STORM,~EVTYPE,summarise,FATAL=sum(FATALITIES), INJ=sum(INJURIES), BOTH=sum(FATALITIES, INJURIES), PROPDAMAGE= sum(PROPDMG), CROPDAMAGE=sum(CROPDMG), TOTALDAMAGE=sum(PROPDAMAGE, CROPDAMAGE))
BadEvents <- EvenTYPES[order(-EvenTYPES$BOTH, -EvenTYPES$FATAL, -EvenTYPES$INJ),]
BadEventsHead<-head(BadEvents, 10)
BadEventsFATAL<-EvenTYPES[order(-EvenTYPES$FATAL),]
BadEVentsFATALhead<-head(BadEventsFATAL, 10)
BadEVentsFATALhead
## EVTYPE FATAL INJ BOTH PROPDAMAGE CROPDAMAGE TOTALDAMAGE
## 834 TORNADO 5633 91346 96979 3212258.2 100018.52 3312276.7
## 130 EXCESSIVE HEAT 1903 6525 8428 1460.0 494.40 1954.4
## 153 FLASH FLOOD 978 1777 2755 1420124.6 179200.46 1599325.1
## 275 HEAT 937 2100 3037 298.5 662.70 961.2
## 464 LIGHTNING 816 5230 6046 603351.8 3580.61 606932.4
## 856 TSTM WIND 504 6957 7461 1335965.6 109202.60 1445168.2
## 170 FLOOD 470 6789 7259 899938.5 168037.88 1067976.4
## 585 RIP CURRENT 368 232 600 1.0 0.00 1.0
## 359 HIGH WIND 248 1137 1385 324731.6 17283.21 342014.8
## 19 AVALANCHE 224 170 394 1623.9 0.00 1623.9
BadEventsINJ<-EvenTYPES[order(-EvenTYPES$INJ),]
BadEVentsINJhead<-head(BadEventsINJ, 10)
BadEVentsINJhead
## EVTYPE FATAL INJ BOTH PROPDAMAGE CROPDAMAGE TOTALDAMAGE
## 834 TORNADO 5633 91346 96979 3212258.16 100018.52 3312276.68
## 856 TSTM WIND 504 6957 7461 1335965.61 109202.60 1445168.21
## 170 FLOOD 470 6789 7259 899938.48 168037.88 1067976.36
## 130 EXCESSIVE HEAT 1903 6525 8428 1460.00 494.40 1954.40
## 464 LIGHTNING 816 5230 6046 603351.78 3580.61 606932.39
## 275 HEAT 937 2100 3037 298.50 662.70 961.20
## 427 ICE STORM 89 1975 2064 66000.67 1688.95 67689.62
## 153 FLASH FLOOD 978 1777 2755 1420124.59 179200.46 1599325.05
## 760 THUNDERSTORM WIND 133 1488 1621 876844.17 66791.45 943635.62
## 244 HAIL 15 1361 1376 688693.38 579596.28 1268289.66
par(mfrow = c(1, 2), mar = c(10, 4, 2, 2), las = 3, cex = 0.7, cex.main = 1.4, cex.lab = 1.2)
barplot(BadEVentsFATALhead$FATAL, names.arg = BadEVentsFATALhead$EVTYPE, col = 'red',
main = 'Top 10 Weather Events for Fatalities', ylab = 'Number of Fatalities')
barplot(BadEVentsINJhead$INJ, names.arg = BadEVentsINJhead$EVTYPE, col = 'orange',
main = 'Top 10 Weather Events for Injuries', ylab = 'Number of Injuries')
Thus we see that Tornados cause most deaths and injuries in the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. But Excessive heat causes second most deaths, whereas as far as injuries are conserned second to fourth causes have very similar values. address the question of which types of events have the greatest economic consequences
Again we will only look at the top 10 event types for both property and crop damage.
#Damages
Damages<- EvenTYPES[order(-EvenTYPES$TOTALDAMAGE, -EvenTYPES$PROPDAMAGE, -EvenTYPES$CROPDAMAGE),]
head(Damages, 10)
## EVTYPE FATAL INJ BOTH PROPDAMAGE CROPDAMAGE TOTALDAMAGE
## 834 TORNADO 5633 91346 96979 3212258.2 100018.52 3312276.7
## 153 FLASH FLOOD 978 1777 2755 1420124.6 179200.46 1599325.1
## 856 TSTM WIND 504 6957 7461 1335965.6 109202.60 1445168.2
## 244 HAIL 15 1361 1376 688693.4 579596.28 1268289.7
## 170 FLOOD 470 6789 7259 899938.5 168037.88 1067976.4
## 760 THUNDERSTORM WIND 133 1488 1621 876844.2 66791.45 943635.6
## 464 LIGHTNING 816 5230 6046 603351.8 3580.61 606932.4
## 786 THUNDERSTORM WINDS 64 908 972 446293.2 18684.93 464978.1
## 359 HIGH WIND 248 1137 1385 324731.6 17283.21 342014.8
## 972 WINTER STORM 206 1321 1527 132720.6 1978.99 134699.6
DamagesCROP<-EvenTYPES[order(-EvenTYPES$CROPDAMAGE),]
DamagesCROPhead<-head(DamagesCROP, 10)
DamagesCROPhead
## EVTYPE FATAL INJ BOTH PROPDAMAGE CROPDAMAGE TOTALDAMAGE
## 244 HAIL 15 1361 1376 688693.38 579596.28 1268289.66
## 153 FLASH FLOOD 978 1777 2755 1420124.59 179200.46 1599325.05
## 170 FLOOD 470 6789 7259 899938.48 168037.88 1067976.36
## 856 TSTM WIND 504 6957 7461 1335965.61 109202.60 1445168.21
## 834 TORNADO 5633 91346 96979 3212258.16 100018.52 3312276.68
## 760 THUNDERSTORM WIND 133 1488 1621 876844.17 66791.45 943635.62
## 95 DROUGHT 0 4 4 4099.05 33898.62 37997.67
## 786 THUNDERSTORM WINDS 64 908 972 446293.18 18684.93 464978.11
## 359 HIGH WIND 248 1137 1385 324731.56 17283.21 342014.77
## 290 HEAVY RAIN 98 251 349 50842.14 11122.80 61964.94
DamagesPROP<-EvenTYPES[order(-EvenTYPES$PROPDAMAGE),]
DamagesPROPhead<-head(DamagesPROP, 10)
DamagesPROPhead
## EVTYPE FATAL INJ BOTH PROPDAMAGE CROPDAMAGE TOTALDAMAGE
## 834 TORNADO 5633 91346 96979 3212258.2 100018.52 3312276.7
## 153 FLASH FLOOD 978 1777 2755 1420124.6 179200.46 1599325.1
## 856 TSTM WIND 504 6957 7461 1335965.6 109202.60 1445168.2
## 170 FLOOD 470 6789 7259 899938.5 168037.88 1067976.4
## 760 THUNDERSTORM WIND 133 1488 1621 876844.2 66791.45 943635.6
## 244 HAIL 15 1361 1376 688693.4 579596.28 1268289.7
## 464 LIGHTNING 816 5230 6046 603351.8 3580.61 606932.4
## 786 THUNDERSTORM WINDS 64 908 972 446293.2 18684.93 464978.1
## 359 HIGH WIND 248 1137 1385 324731.6 17283.21 342014.8
## 972 WINTER STORM 206 1321 1527 132720.6 1978.99 134699.6
par(mfrow = c(1, 2), mar = c(10, 4, 2, 2), las = 3, cex = 0.7, cex.main = 1.4, cex.lab = 1.2)
barplot(DamagesPROPhead$PROPDAMAGE, names.arg = DamagesPROPhead$EVTYPE, col = 'Brown',
main = 'Top 10 Weather Events for Property Damage ', ylab = 'Amount of Property Damage', ylim = c(0, 3500000))
barplot(DamagesCROPhead$CROPDAMAGE, names.arg = DamagesCROPhead$EVTYPE, col = 'Green',
main = 'Top 10 Weather Events for Crop Damage', ylab = 'Amount of Crop Damage', ylim = c(0, 3500000))
We can see tornadoes cause the most harm for both Fatalities/Injuries and Property damage.