Next, I will demonstrate the use of the ggplotly() function which converts a ggplot object to a plotly object.
I include code below that creates a ggplot object showing the number of visitors in each year from 2009-2018 for three of the lesser-visited parks, Channel Islands, Pinnacles, and Redwoods.
parksToKeep <- c('Channel Islands', 'Pinnacles', 'Redwoods')
p <- ggplot(data = data %>%
filter(park %in% parksToKeep),
aes(x = year, y = visitors, colour = park)) +
geom_point(size = 2) + geom_path(aes(group = park), size = 1) +
scale_color_brewer(palette = "Accent") +
theme_minimal()