Eric Lim B G
22 February 2015
Coursera: Developing Data Products (Rpres)
Storms and other severe weather events cause both public health and economic problems for communities and municipalities across the United States
A shiny application has been developed to help visualise this events using data from the U.S. National Oceanic and Atmospheric Administration's (NOAA) storm database
The shiny application is composed of:
A subset of NOAA's storm database were extracted for the shiny application. Its structure is as shown below:
data <- read.csv('data/usstormdata.csv')
str(data)
'data.frame': 17614 obs. of 7 variables:
$ YEAR : int 1950 1951 1952 1953 1954 1955 1955 1955 1956 1956 ...
$ STATE : Factor w/ 50 levels "alabama","alaska",..: 1 1 1 1 1 1 1 1 1 1 ...
$ EVTYPE : Factor w/ 18 levels "AVALANCHE","BLIZZARD / WINTER STORM / WEATHER",..: 15 15 15 15 15 10 14 15 10 14 ...
$ FATALITIES: int 0 0 6 16 0 0 0 5 0 0 ...
$ INJURIES : int 15 13 116 248 36 0 0 27 0 0 ...
$ PROPDMG : num 0.0275 0.035 5.4525 3.07 0.6075 ...
$ CROPDMG : num 0 0 0 0 0 0 0 0 0 0 ...
The main interaction between the shiny UI and Server is in filtering the underlying plot data (see below)
filterdata<-reactive({
replace_na<-function(x) ifelse(is.na(x),0,x)
round_2<-function(x) round(x,2)
aggregated<-rawdata%>%
filter(YEAR>=input$period[1],
YEAR<=input$period[2],
EVTYPE %in% input$evtypes)%>%
group_by(STATE)%>%
summarise_each(funs(sum),
FATALITIES:CROPDMG)%>%
mutate_each(funs(replace_na),
FATALITIES:CROPDMG)%>%
mutate_each(funs(round_2),PROPDMG,CROPDMG)
})
Filtered data drived from interactions between the shiny UI and Server is plotted in a geospatial chart (shown below)