Exercise 4: Time series plot - all diseases in the United States
Now we are going to make a time series plot for the rates of all diseases in the United States. For this exercise, we have provided less sample code - you can take a look at the previous exercise to get you started.
This exercise is part of the course
Data Science Visualization - Module 2
Exercise instructions
- Compute the US rate by using
summarize
to sum over states. Call the variablerate
.- The US rate for each disease will be the total number of cases divided by the total population.
- Remember to convert to cases per 10,000.
- You will need to filter for
!is.na(population)
to get all the data. - Plot each disease in a different color.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(dplyr)
library(ggplot2)
library(dslabs)
library(RColorBrewer)
data(us_contagious_diseases)