Plotly Assignment

Created October 3, 2017

Below is a graph created with Plotly that shows the number of cases of Ebola in West Africa in 2014. Countries considered in this data set were Guinea, Liberia, Mali, Senegal and Sierra Leone. The data set came from Plotly Datasets on Github.

library(plotly)
## Warning: package 'plotly' was built under R version 3.4.1
# pull in 2014 Ebola data
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_ebola.csv')



# build data frame with just Months and Cases per month for plot
df1 <- data.frame(Month = df$Month, Cases = df$Value)
# ordered factor variable with month abbreviations as a new column
df1$abbrev <- ordered(month.abb[df$Month], levels = month.abb[1:12])
# remove any cases with NA
df1 <- df1[complete.cases(df1),]

# plot cases per month
p <- plot_ly(x = df1$abbrev, y = df1$Cases) %>%
        layout(title = "Ebola Cases in 2014 by Month in West Africa",
        xaxis = list (title = "Month"),
       yaxis = list(title = "Number of Cases of Ebola"))
# print graph
p