September 14, 2018

Project Instructions

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

Review Criteria:

  1. Does the web page feature a date and is this date less than two months before the date that you're grading this assignment?
  2. Is the web page a presentation and does it feature an interactive plot that appears to have been created with Plotly?

Introduction and Data Description

For my project, I used a dataset provided by the National Weather Service which details severe weather event fatalities for 78 years, 1940 to 2017. However, I only examined 17 years worth of data from 2000 to 2017. Possible types of weather event fatalities include: cold related, flood, heat related, hurricane, lightning, rip current, tornado, wind, winter related, or other.

Data Analysis

Load the required libraries and read the data into R

library(plotly)
library(dplyr)
library(formatR)
weather_event_deaths <- read.csv("/Users/dad/Documents/Coursera/Data-Science-Specialization/Course9DevelopingDataProducts/CourseProject2/weather_fatalities.csv", 
    header = TRUE, sep = ",")

Data Analysis

Take a look at the data summary

summary(weather_event_deaths)
##       Year      Percentage_of_Total_Deaths Weather_Event_Type
##  Min.   :2000   Min.   :0.00000            Cold     :18      
##  1st Qu.:2004   1st Qu.:0.04496            Flood    :18      
##  Median :2008   Median :0.08446            Heat     :18      
##  Mean   :2008   Mean   :0.10000            Hurricane:18      
##  3rd Qu.:2013   3rd Qu.:0.12293            Lightning:18      
##  Max.   :2017   Max.   :0.70021            Other    :18      
##                                            (Other)  :72

Display Code to Create Plot of Weather Event Fatalities Using Plotly

R code to create weather event fatalities plot using 'plotly'

plot <- plot_ly(weather_event_deaths, x = ~Year, 
    y = ~Percentage_of_Total_Deaths, color = ~Weather_Event_Type, 
    type = "scatter", mode = "lines") %>% 
    layout(title = "Weather Event Fatalities as a Percentage of 
        all Weather Related Fatalities", 
        xaxis = list(title = "Year", yaxis = list(title = "% of 
        Total Deaths")))

Display Plot Created with Plotly

plot