SYNOPSIS :

Storm Data is officially published by National Oceanic and Atmospheric Administration (NOAA). Every year storms and other weather events create enough intensity to cause damages, life losses, and property and crop damages. Because of this nation faces enormous amount of financial and personal losses which is irreparable. The database currently contains data from January 1950 to August 2017.The changes in Data collection and processing procedures are changing from time to time. So unique periods of records are available as per the “Event type”. Hence as per the necessity, data reformatting and standardization of event types has been done. This project explores 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.

DATA :

The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. You can download the file from the given link: “https://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2” The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete. #VARIABLES INCLUDED IN THE DATASET: This dataframe has 37 variables, out of which 8 variables will be used for analysis purpose.These are listed down: STATE,EVTYPE,FATALITIES,INJURIES,PROPDMG,PROPDMGEXP,CROPDMG,CROPDMGEXP. #LOADING AND PREPROCESSING OF THE DATA

dim(fullstormdata)
## [1] 902297     37
str(fullstormdata)
## '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 ...

DATA PROCESSING

stormdata <- fullstormdata[, c("STATE","EVTYPE","FATALITIES","INJURIES","PROPDMG","PROPDMGEXP","CROPDMG","CROPDMGEXP")]
sum(is.na(stormdata))
## [1] 0
head(stormdata)
##   STATE  EVTYPE FATALITIES INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP
## 1    AL TORNADO          0       15    25.0          K       0           
## 2    AL TORNADO          0        0     2.5          K       0           
## 3    AL TORNADO          0        2    25.0          K       0           
## 4    AL TORNADO          0        2     2.5          K       0           
## 5    AL TORNADO          0        2     2.5          K       0           
## 6    AL TORNADO          0        6     2.5          K       0
summary(stormdata)
##      STATE                      EVTYPE         FATALITIES      
##  TX     : 83728   HAIL             :288661   Min.   :  0.0000  
##  KS     : 53440   TSTM WIND        :219940   1st Qu.:  0.0000  
##  OK     : 46802   THUNDERSTORM WIND: 82563   Median :  0.0000  
##  MO     : 35648   TORNADO          : 60652   Mean   :  0.0168  
##  IA     : 31069   FLASH FLOOD      : 54277   3rd Qu.:  0.0000  
##  NE     : 30271   FLOOD            : 25326   Max.   :583.0000  
##  (Other):621339   (Other)          :170878                     
##     INJURIES            PROPDMG          PROPDMGEXP        CROPDMG       
##  Min.   :   0.0000   Min.   :   0.00          :465934   Min.   :  0.000  
##  1st Qu.:   0.0000   1st Qu.:   0.00   K      :424665   1st Qu.:  0.000  
##  Median :   0.0000   Median :   0.00   M      : 11330   Median :  0.000  
##  Mean   :   0.1557   Mean   :  12.06   0      :   216   Mean   :  1.527  
##  3rd Qu.:   0.0000   3rd Qu.:   0.50   B      :    40   3rd Qu.:  0.000  
##  Max.   :1700.0000   Max.   :5000.00   5      :    28   Max.   :990.000  
##                                        (Other):    84                    
##    CROPDMGEXP    
##         :618413  
##  K      :281832  
##  M      :  1994  
##  k      :    21  
##  0      :    19  
##  B      :     9  
##  (Other):     9

RESULTS (FOR FATALITIES AND INJURIES)

fatality <- aggregate(FATALITIES ~ EVTYPE, data = stormdata, FUN = sum)
fatality1 <- fatality[order(-fatality$FATALITIES),][1:20,]
head(fatality1)
##             EVTYPE FATALITIES
## 834        TORNADO       5633
## 130 EXCESSIVE HEAT       1903
## 153    FLASH FLOOD        978
## 275           HEAT        937
## 464      LIGHTNING        816
## 856      TSTM WIND        504
injury <- aggregate(INJURIES ~ EVTYPE, data = stormdata, FUN = sum)
injury1 <- injury[order(-injury$INJURIES),][1:20,]
head(injury1)
##             EVTYPE INJURIES
## 834        TORNADO    91346
## 856      TSTM WIND     6957
## 170          FLOOD     6789
## 130 EXCESSIVE HEAT     6525
## 464      LIGHTNING     5230
## 275           HEAT     2100

RESULTS FOR PROPERTY DAMAGE

unique(stormdata$PROPDMG)
##    [1]   25.00    2.50  250.00    0.00    0.03    0.25    5.00    0.10
##    [9]   50.00  500.00   48.00   20.00    2.00   35.00    3.00    0.50
##   [17]  900.00    1.00    4.00   10.00    1.50   45.00    0.20   12.00
##   [25]    8.00   22.00   55.00   40.00   14.00   85.00   42.00   15.00
##   [33]  100.00   30.00    0.05   38.00   80.00   18.00    0.65    6.00
##   [41]    0.30   24.00   32.00    7.00   28.00   70.00   95.00   65.00
##   [49]    0.40   90.00   37.00  200.00   23.00   56.00    0.45    7.50
##   [57]  150.00   47.00    4.10    5.50   98.00    1.60    1.30    0.01
##   [65]    3.50    0.02   75.00    0.60    4.80  331.00  619.00   60.00
##   [73]    0.41    0.84   11.00    1.70    4.50  400.00   17.00  450.00
##   [81]  240.00    0.70  300.00  230.00    2.10    0.86  571.00  600.00
##   [89]    2.80  800.00  120.00  700.00  275.00    1.10  175.00  204.00
##   [97]  125.00  350.00    6.50  135.00    9.00  650.00    0.80    0.90
##  [105]    1.40    3.40  110.00    1.90    0.17    3.30    7.70   26.00
##  [113]    7.60  106.00  518.00   88.00    6.40    1.20    8.20    8.30
##  [121]    5.40    4.40  270.00    1.80    4.30  140.00  130.00    3.80
##  [129]    2.40  750.00    4.90  105.00  850.00   16.00  330.00  303.00
##  [137]   34.00  176.00    0.15    0.13    6.70    8.50    0.06    2.20
##  [145]  630.00    4.20    5.20    8.70  155.00    2.70  195.00    3.20
##  [153]  180.00    8.40  160.00  897.00  132.00  185.00  192.00   61.00
##  [161]  810.00  374.00   13.00  118.00  170.00   68.00  475.00    3.60
##  [169]  145.00  260.00  210.00  415.00  220.00  115.00    3.90  375.00
##  [177]  460.00  225.00   62.00    0.08    0.07    4.60    0.04  325.00
##  [185]    6.60   43.00  675.00    0.35   78.00   27.00   67.00    6.20
##  [193]   36.00   53.00  380.00  595.00    1.25  320.00   63.00    0.75
##  [201]   12.30   37.40  520.00   31.00  470.00   44.60   44.00   13.50
##  [209]   44.70   14.50   21.50  530.00  183.50   12.50    1.84   99.00
##  [217]  550.00   52.00    2.90   12.80    1.07    7.20    5.47  594.00
##  [225]  231.00  561.00  570.00    2.33   10.20   14.98    1.14   10.75
##  [233]   14.96   41.70    5.80   19.00  733.40  680.00  620.00   58.00
##  [241]   18.80   14.20   10.72  720.00    1.68   73.00  640.00    7.90
##  [249]   17.80    5.70    9.30    6.55  133.00   21.00   29.00   89.00
##  [257]   11.50   41.00   14.40    2.01  310.00  140.25  510.00  792.15
##  [265]   14.25    3.37  187.00    3.72    5.09    1.26    3.43  352.00
##  [273]  529.00  128.00    5.25  280.00   10.50   71.50   18.97   21.10
##  [281]    9.90   17.90   19.50   21.30   20.10   12.71    9.60   42.31
##  [289]    4.38   71.00    3.05  670.00   69.00  780.00  490.00  635.00
##  [297]    1.16  440.00  324.00    2.03    6.30    0.11   12.60    2.82
##  [305]  560.00    7.51   77.00  265.00   78.74   31.50    9.50    4.52
##  [313]    2.41    4.12   21.70   16.50   33.00    5.30  480.00   39.50
##  [321]   39.00   54.00  410.00   64.00    2.30   60.50    1.76    1.75
##  [329]   30.30  190.00    3.45  215.00  940.00   17.70    3.10  114.00
##  [337]   12.90  525.00  214.00    2.95   17.50    2.75  536.00    2.25
##  [345]   49.00    1.04    7.80  126.00    2.55  297.08   88.15   55.60
##  [353]  207.00   15.20    1.85   11.85    8.45    2.45    5.08    5.05
##  [361]   28.50    9.76  693.40  203.00  253.00   37.50   79.98  100.02
##  [369]    0.99   49.98    4.96    1.18    1.35   22.88  160.80   57.12
##  [377]    0.51    7.30    0.78    9.80  269.00    1.05   56.50  108.00
##  [385]    1.78  219.00    4.26   81.00  196.00  107.00   72.00  184.00
##  [393]  425.00  165.00   55.08    6.32    3.04   96.00   44.72  102.00
##  [401]   46.00  540.00    0.55    5.10   76.60   79.00  917.00  205.00
##  [409]  286.00  147.00   24.70  106.72    4.70    0.66    0.12   98.26
##  [417]   19.79    0.76  655.00  585.00   42.40    4.25  385.00  770.00
##  [425]  149.00   78.70    5.38   20.40  388.50  151.40  159.00   91.00
##  [433]  382.00  174.16   46.80   13.90   20.80    4.29  880.00   29.70
##  [441]   35.90   10.30  262.00  365.00  348.00    1.06   87.80  117.00
##  [449]  645.00   25.52  437.00  367.00    1.13  284.00  255.00   61.98
##  [457]  161.00  435.00   88.50   51.00  312.00    1.02   29.96  229.90
##  [465]  299.88    8.65    8.90   30.70   17.30  250.03    1.49   82.00
##  [473]    6.25   32.50    1.65  775.00  218.00   31.95  304.00   31.52
##  [481]   30.06  347.00  463.00  766.00  515.00    4.02   24.21   34.63
##  [489]    1.11    1.24   86.60   49.34  373.00  502.70  610.00  405.00
##  [497]    3.25  315.00  825.00    9.20   17.60    0.85  602.00    2.78
##  [505]   16.60  233.00   23.70   26.87   17.03    2.66    1.86  745.00
##  [513]  212.00  154.00  575.00   66.00  100.03   22.18  482.00   26.20
##  [521]   13.40  305.00  535.00  505.00   24.50   15.50   18.50   54.10
##  [529]   97.00  193.00   99.97  360.00  413.50    3.83  166.00  499.92
##  [537]  970.00  172.00    0.21    1.51    3.70  287.18  268.00   76.00
##  [545]    5.75  101.00   23.55    5.55   66.50  467.00  914.00    3.64
##  [553]    3.13  875.00    3.71  642.00    8.57    3.46   19.20   57.00
##  [561]  950.00  845.00  167.00   22.14    4.74    1.72   10.36  346.00
##  [569]  245.00  370.00    2.05  227.00   66.90  290.00   13.30   22.20
##  [577]   13.80   25.13    4.15  224.00    5.90   13.47  758.00  890.00
##  [585]  186.00  690.00    7.55   94.00    1.58   27.50    1.55    2.48
##  [593]   82.50    6.68  178.40  138.60    3.15  278.00    2.60  547.00
##  [601]    1.77  960.00   92.00    2.77   22.50  431.72  570.45    1.15
##  [609]  358.00  174.40    2.73    3.74  500.01  975.00  920.00  499.96
##  [617]  410.62  109.00    2.58  590.00    1.01  328.00  910.00   56.54
##  [625]  932.00    4.71    2.52    1.47   20.02  295.00  476.00  237.00
##  [633]  738.00   72.70   74.00    6.51  990.00   11.10    7.72   99.39
##  [641]  617.00  153.00  870.00  654.00  122.00  148.00   83.00   78.20
##  [649]   22.70  662.00  665.00   48.02   47.30  625.00   75.30  130.02
##  [657]    1.27  925.00   76.30  127.00  235.00  271.00  378.00  343.00
##  [665]    6.07  755.00  285.00    8.43   84.00    3.31  166.50  183.00
##  [673]  557.00  363.00  111.00  502.00   59.00   46.50  151.00  103.00
##  [681]   14.60    4.43   74.25    1.88  500.40  510.07  116.00  508.00
##  [689]  123.00  229.00  465.00    4.57   10.40   32.20    9.25   96.80
##  [697]  583.00    6.05    1.53    6.82  179.50  153.55  787.00  501.00
##  [705]  565.00  840.00  777.80    6.06  144.00    7.05    6.10  606.00
##  [713]  279.00   16.90    1.46  936.00  382.50   16.05    4.65    1.95
##  [721]  420.00  173.00    2.27   17.14  548.00  209.00  112.00  322.20
##  [729]  134.00   15.75  955.00  354.00   50.02    1.48  113.00  390.00
##  [737]  815.00  586.00  604.00    3.57    1.79  760.00  100.50  146.50
##  [745]   25.50  149.85   33.50    1.28  785.00  213.00    1.37  266.00
##  [753]    5.15    3.75  713.00  888.00   11.60    6.45    7.45    4.06
##  [761]    1.38   65.50    5.60  988.00    2.16   10.05    3.68  830.00
##  [769]    3.78   14.30   45.70   12.70   15.30    3.96  158.00   11.18
##  [777]   11.02  142.00   11.65  485.00  308.00    5.74  554.00  762.00
##  [785]    9.51  202.00  381.00   93.00   26.50    5.76   15.60  108.63
##  [793]  149.58  368.00  820.00   18.54   13.25   13.36   14.26  138.00
##  [801]  479.00    5.94    6.75  971.00    8.85    1.61    3.55   45.50
##  [809]  580.00    6.80  162.00  335.00  201.00    0.22  968.00  459.00
##  [817]  189.00   16.20  577.00  345.00  261.00    4.45   11.15    3.28
##  [825]    1.59  824.00  460.56    1.54  806.77  696.40   55.22  278.60
##  [833]   16.96    3.24  979.00   16.10   17.75  337.00    9.17  935.00
##  [841]  179.00  257.00   41.60  645.15   39.60  246.00    1.34   26.30
##  [849]   19.64    2.35    5.24    2.46  530.47    1.81  161.11   21.20
##  [857]   14.70  137.90  725.00    1.29  430.00    2.65   28.55    1.69
##  [865]  954.00  710.00  435.60    7.29  534.00    1.33    2.32    3.54
##  [873]   32.22   18.05    0.95  493.00  206.00  141.00    2.81    3.92
##  [881]   11.62    5.58   13.95   23.23   16.74    9.31   11.16    4.22
##  [889]    8.37  283.00   10.88   19.77   21.88    1.45    8.87    3.02
##  [897]  506.00   45.07   55.10    1.82   16.87    4.86   44.50    8.60
##  [905]   13.53   12.05   51.50  340.00  104.00   19.90   12.20    1.92
##  [913]    8.09  163.50  177.00  143.00    5.42  929.00  621.00    4.83
##  [921]   23.50  127.20  179.40    1.74   90.43  379.90  323.00  702.00
##  [929]  134.80    2.53    2.19  613.00    5.51   14.28  327.00    2.22
##  [937]  758.25  661.00  242.00    3.53    1.43   97.20  136.00   11.83
##  [945]  355.00   16.25    6.67    1.23    6.63   10.43    4.51    4.17
##  [953]    3.11    1.03    2.36   12.40    8.10  243.00  605.00   54.90
##  [961]  451.00   19.30   10.15   30.50   49.94  277.00    5.13    6.14
##  [969]  478.00   23.20    0.81   10.25  359.00    2.57  706.00   43.60
##  [977]    8.25   53.80  438.00    1.41  353.00   35.55  876.00  915.00
##  [985]  178.00   34.89    2.69   38.50   20.50  198.50  868.50   55.90
##  [993]   60.80    1.71    8.80    7.15    6.90   13.15  148.25    9.77
## [1001]  930.00    3.94  270.75  163.00  246.10   50.10  952.50  168.00
## [1009]   11.70  740.00    2.54    4.85  288.00   47.50   16.93   31.30
## [1017]  432.00    5.99  643.00  442.00  545.00  445.00    7.35   11.26
## [1025]    5.88  746.00  701.00    7.64  973.00  724.00  945.00  257.95
## [1033]   19.94  179.61   79.20   42.16  124.90    8.97    1.73    3.65
## [1041]   22.75    1.62  348.10    0.16   86.00   87.00    2.09  159.50
## [1049]  139.00    5.16  592.00   40.50   34.31  171.00   40.20    7.75
## [1057]  411.14  280.10  531.10    9.72  357.00  137.00  249.00  121.70
## [1065]  411.00    1.57    3.47    1.87  146.00  996.00    1.32  552.00
## [1073]  259.00  164.00  524.00  623.00    5.27   10.10  632.00  887.00
## [1081]  294.00    9.06  660.00  995.00   10.80   49.90   94.50   89.50
## [1089]   36.20   28.68  569.00    1.99    4.44    4.36    2.38    3.17
## [1097]    6.34   12.06  542.00   31.90   31.70   31.60  151.10   76.50
## [1105]  208.00  989.00  129.00  434.00  377.00    1.44    1.56  338.00
## [1113]    4.84   21.60   81.15   18.20  314.00  297.00  472.00   41.50
## [1121]  612.00    9.70   62.60  124.00   18.30  556.00    0.18    7.77
## [1129]  823.00   16.70    1.91   11.90   28.20    1.36    2.67  777.00
## [1137]    0.33    0.26    0.36  234.00    2.47   36.25  444.59  431.00
## [1145]  576.00    1.89  121.00   16.80  226.00  684.00    9.75   19.40
## [1153]    2.63   20.20   22.85    9.40    6.74  370.40  366.50  727.00
## [1161]  481.00  274.00  957.00  242.80  639.00  581.00  291.00    4.93
## [1169]   28.40   10.69    7.10   22.60   96.60   63.70  128.70   18.40
## [1177]   14.10  156.50    4.94  691.00  686.00   13.71    7.93    8.75
## [1185]    6.57  429.00    4.64  102.22   62.99    1.97   77.97   15.66
## [1193]  462.00    2.15   22.40  525.60    2.83  462.16  402.30   18.60
## [1201]   13.54  453.00   13.20 3000.00  157.00 4410.00  748.00  264.00
## [1209]  553.00  603.00  342.00  558.00   14.80  152.00  191.00  161.20
## [1217]  555.00  216.00  488.00  166.67  177.50  813.00   68.60   49.50
## [1225]  715.00   52.50 3500.00  901.60  167.50   13.13   12.29  252.00
## [1233]    3.85   35.50   12.17  222.00  321.00 5000.00  964.00  397.50
## [1241]    0.63   11.40    0.74    7.44  455.00   44.52    0.87    5.63
## [1249]    3.18   21.75    0.34    8.48   10.44    0.23    5.85    1.17
## [1257]    5.52 1000.00  362.00  241.00 4800.00   17.92    3.33  119.00
## [1265]   13.67    3.27   16.15   10.70   26.43   11.79   23.58   25.65
## [1273]    4.05    8.07   70.90   24.76   26.64    5.91    3.52    8.32
## [1281]   16.64  349.00    8.81  868.00  598.00  232.00  859.00   11.30
## [1289]   77.80   28.90    3.95    3.34  112.50   29.50 3200.00  258.00
## [1297]  150.20   55.50   20.60  211.00  253.38  892.00  433.70    5.64
## [1305]   24.10  272.00  257.40  297.30  934.30   20.90  423.00    3.03
## [1313]    4.59    3.29  217.00  402.00   17.20    1.63    6.61  418.00
## [1321]   19.70    1.96  309.00    3.81  182.00  296.70   25.90    6.53
## [1329]   10.60    2.26  267.00    1.19  855.00 1584.00  333.00   26.60
## [1337]  262.50  767.00  426.00    1.21  685.00    1.66  557.50   10.90
## [1345]    4.75    4.37  643.90  676.00    1.08    3.56   11.20  282.00
## [1353]    6.88    2.98    3.91  572.00    4.27    2.07    1.83   83.80
## [1361]    7.06   45.80    3.48   88.75  371.00  865.00  730.00  458.00
## [1369]  615.00   15.25   39.80    3.99    2.28  688.00  716.00  752.00
## [1377]    2.72  276.00  311.00  667.00   53.90  227.60  461.00  351.50
## [1385]   27.10   40.30   69.70  164.80  181.00   43.50
unique(stormdata$PROPDMGEXP)
##  [1] K M   B m + 0 5 6 ? 4 2 3 h 7 H - 1 8
## Levels:  - ? + 0 1 2 3 4 5 6 7 8 B h H K m M

Transformation of exponential form to actual values (PROPERTY DAMAGE)

stormdata$PROPDMG[stormdata$PROPDMGEXP == "K" ] <- 10^3
stormdata$PROPDMG[stormdata$PROPDMGEXP == "M" ] <- 10^6
stormdata$PROPDMG[stormdata$PROPDMGEXP == " " ] <- 1
stormdata$PROPDMG[stormdata$PROPDMGEXP == "B"] <- 10^9
stormdata$PROPDMG[stormdata$PROPDMGEXP == "m"] <- 10^6
stormdata$PROPDMG[stormdata$PROPDMGEXP == "+" ] <- 0
stormdata$PROPDMG[stormdata$PROPDMGEXP == "0" ] <- 1
stormdata$PROPDMG[stormdata$PROPDMGEXP == "5" ] <- 10^5
stormdata$PROPDMG[stormdata$PROPDMGEXP == "6" ] <- 10^6
stormdata$PROPDMG[stormdata$PROPDMGEXP == "?" ] <- 0
stormdata$PROPDMG[stormdata$PROPDMGEXP == "4" ] <- 10^4
stormdata$PROPDMG[stormdata$PROPDMGEXP == "2" ] <- 10^2
stormdata$PROPDMG[stormdata$PROPDMGEXP == "3" ] <- 10^3
stormdata$PROPDMG[stormdata$PROPDMGEXP == "h" ] <- 10^2
stormdata$PROPDMG[stormdata$PROPDMGEXP == "7" ] <- 10^7
stormdata$PROPDMG[stormdata$PROPDMGEXP == "H" ] <- 10^2
stormdata$PROPDMG[stormdata$PROPDMGEXP == "-" ] <- 0
stormdata$PROPDMG[stormdata$PROPDMGEXP == "1" ] <- 10^1
stormdata$PROPDMG[stormdata$PROPDMGEXP == "8" ] <- 10^8

RESULT FOR CROP DAMAGE

unique(stormdata$CROPDMG)
##   [1]   0.00  10.00 500.00   1.00   4.00  50.00   5.00  15.00   0.50   0.40
##  [11]   0.05  21.00   7.00  17.00  26.00  22.00   3.00   0.80  39.00  20.00
##  [21] 300.00   0.90  48.00   0.20   1.50   2.50   2.00 200.00  25.00 130.00
##  [31]  37.00   9.00  45.00 185.00  35.00   2.20  12.00   0.30  90.00   0.15
##  [41] 100.00  66.00 142.00   1.10   0.70 330.00 750.00   6.00  43.00  60.00
##  [51] 150.00   1.80 250.00  40.00   0.02   1.30  30.00  70.00   0.01  80.00
##  [61] 350.00 400.00   8.00  75.00   3.50  63.00  18.00   0.28   0.10   1.70
##  [71]   0.75   4.70  16.00 170.00 600.00 125.00   6.70   2.10 675.00   0.60
##  [81] 262.00 332.00 220.00  56.00   0.03 353.00 177.00  36.00 373.00 430.00
##  [91] 160.00 123.00  13.00 140.00  38.00  52.00   0.24 320.00   7.70   3.70
## [101]   6.80   1.20 380.00   6.50   5.60  74.90  34.10  15.30  24.00   5.10
## [111]  27.00  42.00 800.00 650.00 230.00  10.50  55.00   1.58   5.99   1.25
## [121]   3.60   5.20   3.25   5.25   3.22 204.00   2.40 127.00   7.50  46.00
## [131]  33.00 900.00 120.00 700.00   2.25  19.80   4.50 189.68   1.05  81.00
## [141] 225.00  37.50   5.40   7.55   1.40  26.84   5.70 500.10 950.00  15.70
## [151]  11.00  17.50 110.00   1.12  55.70   1.60  12.90  20.04  46.50  65.00
## [161]   4.80   1.48  43.68 613.00  14.00  19.00   3.40 850.00 450.00 240.00
## [171]   1.27   2.80  34.48  13.40  23.00  17.96  63.77   9.38  12.40   9.90
## [181]   1.21  12.50   7.80 159.00 242.00 280.00  14.10   4.20   6.90   4.97
## [191] 540.00 713.00   7.20   5.90  73.60   7.10  10.20   5.30  17.10 596.00
## [201]  74.30 470.00 655.00 460.00 180.00   2.90 260.10 145.00   5.50   3.80
## [211]   1.75 978.00 137.90  77.48  28.00  41.50 190.00   0.25   6.21  68.00
## [221]  11.70  85.00 117.00  64.00   6.10   2.60  97.00   3.75 150.20 167.90
## [231] 135.00   1.55  11.50   3.11  38.80 550.00 310.00 186.00  88.00 105.00
## [241]   1.77 149.70 301.00   4.66  22.70   3.39  15.65 131.01   8.80  29.10
## [251] 475.00 338.00  12.30   8.30  11.80 875.00   2.70 465.00 109.92 154.00
## [261] 575.00 660.00  39.85 413.60  63.40  20.30   4.91 640.00  22.60  83.00
## [271]  41.66  42.30 420.00  61.00 865.00 306.72 210.00  13.50 325.00 975.00
## [281] 150.08 160.96   1.85 169.60  80.85   8.50  29.00 605.00 399.84  44.00
## [291]  32.00 175.00   1.90 102.30 515.00   1.56   8.40 151.00  31.90  10.45
## [301]   1.96   6.03   6.85  78.00   1.65 578.85  25.01  24.27 256.00   6.63
## [311]  53.00 115.00   4.40 510.00 168.00 480.00  25.20  65.05  24.50   4.43
## [321] 275.00   8.90  13.20   9.60   7.81  10.80   1.93 312.48 261.00 270.00
## [331]   4.81   8.55 156.50 335.00  14.25  10.92   7.14   1.33  11.96 290.00
## [341]  31.00 285.00  93.20  82.50   8.70  48.40  26.50  15.20  21.60   4.60
## [351] 500.80 990.00   2.85 576.00 920.00 890.00 216.00 101.50  49.00  47.00
## [361]  21.94 671.00   8.60  32.50 423.00  66.50  26.36 180.11  48.46  10.19
## [371]   1.35 154.69 630.00  42.65   1.47 415.00   5.80   2.15   1.51   2.33
## [381]   2.65   8.49  11.68  34.50 113.90  22.32 193.90  11.94 112.50  16.60
## [391]   9.10 492.40  77.00  15.10   2.30  76.50  22.20 985.00  45.40   9.40
## [401]   4.16  26.32   5.92   2.47  73.00 155.00 344.00 620.00 390.00 316.00
## [411] 153.00 523.00  67.00 387.00 243.00 213.00 610.00  99.00 625.00 133.00
## [421] 169.00 588.00 512.00 375.00 112.00 425.00 286.00 281.00 165.00 107.00
## [431]  91.00  41.00
unique(stormdata$CROPDMGEXP)
## [1]   M K m B ? 0 k 2
## Levels:  ? 0 2 B k K m M

Transformation of exponential form to actual values (CROP DAMAGE)

stormdata$CROPDMG[stormdata$CROPDMGEXP == "M"] <- 10^6
stormdata$CROPDMG[stormdata$CROPDMGEXP == "K"] <- 10^3
stormdata$CROPDMG[stormdata$CROPDMGEXP == "m"] <- 10^6
stormdata$CROPDMG[stormdata$CROPDMGEXP == "B"] <- 10^9
stormdata$CROPDMG[stormdata$CROPDMGEXP == "?"] <- 0
stormdata$CROPDMG[stormdata$CROPDMGEXP == "0"] <- 1
stormdata$CROPDMG[stormdata$CROPDMGEXP == "k"] <- 10^3
stormdata$CROPDMG[stormdata$CROPDMGEXP == "2"] <- 10^2

RESULTS FOR PROPERTY AND CROP DAMAGE :

propdamage <- aggregate(PROPDMG ~ EVTYPE, data = stormdata, FUN = sum)
propdamage1 <- propdamage[order(-propdamage$PROPDMG),][1:20,]
head(propdamage1)
##                EVTYPE     PROPDMG
## 411 HURRICANE/TYPHOON 12046012000
## 834           TORNADO  7533649062
## 170             FLOOD  6541863008
## 402         HURRICANE  3077046000
## 153       FLASH FLOOD  2553639217
## 244              HAIL  2068898599
cropdamage <- aggregate(CROPDMG ~ EVTYPE, data = stormdata, FUN = sum)
cropdamage1 <- cropdamage[order(-cropdamage$CROPDMG),][1:20,]
head(cropdamage1)
##                EVTYPE    CROPDMG
## 95            DROUGHT 4143373001
## 411 HURRICANE/TYPHOON 1021011000
## 192            FREEZE 1012002000
## 590       RIVER FLOOD 1005014000
## 427         ICE STORM 1004956000
## 275              HEAT 1003627000

PLOTTING FOR FATALITIES AND INJURIES

par(mfrow = c(1,2), mar = c(12,4,3,2), mgp = c(3,1,0), las=3, cex=0.8)
barplot(fatality1$FATALITIES,names.arg = fatality1$EVTYPE,ylim = c(0,7000), col = heat.colors(20),
        ylab = "No of Fatality",main = "20 Natural Events cause most fatality")

barplot(injury1$INJURIES,names.arg = injury1$EVTYPE,ylim = c(0,10000), col = rainbow(20),
        ylab = "No of Injuries",main = "20 Natural Events cause most injury")

The above plot is shown that tornado creates more fatalities and injuries. #PLOTTING FOR PROPERTY AND CROP DAMAGE

par(mfrow = c(1,2), mar = c(12,4,3,2), mgp = c(3,1,0), las=3, cex=0.8)
barplot(propdamage1$PROPDMG,names.arg = propdamage1$EVTYPE,col = heat.colors(20),
        ylab = "Cost  of property damage in billion $",main = "20 Natural Events cause most property damage")

barplot(cropdamage1$CROPDMG,names.arg = cropdamage1$EVTYPE,col = rainbow(20),
        ylab = "Cost of crop damage in billion $",main = "20 Natural Events cause most crop damage")

From the above plot, we can realize that flood plays main role to damage crops. #CONCLUSION: Storm and other hazards are the biggest disaster to the mankind.The analysis of NOAA storm database made us to understand that tornado has caused the highest number of fatalities and casualities. Huricane created lots of damages to properties and crop damage is happened due to drought across United States.