Highlighting time series data
How did the Housing Price Index (HPI) change from 2000 to 2017 in the United States? In chapter 1 you created a basic time series plot that could start your investigation, but the inability to highlight an individual states' data was limiting. In this exercise, your task is to enable highlighting by state and investigate which states experienced the largest changes in HPI after the recession that started in December 2007.
plotly
and crosstalk
have already been loaded, and the code used to previously create the time series plot is shown.
This exercise is part of the course
Intermediate Interactive Data Visualization with plotly in R
Exercise instructions
- Create a
SharedData
object to enable the selection of an individual states' data. - Complete the plotting pipeline to create a time series plot of
house_price
againstyear
bystate
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create a shared data object keyed by individual states
state_data <- us_economy %>%
___$___(___)
# Using the shared data, plot house price vs. year
state_data %>%
___ %>%
# Group by state
___ %>%
# Add lines
___