library(plotly)
library(dplyr)
library(crosstalk)

# find the 9 most variable time-series
tx9 <- txhousing %>%
  group_by(city) %>%
  summarise(v = var(median, na.rm = TRUE)) %>%
  top_n(9)

# filter original data down to the 9 most variable cities
# and define year as the "interaction unit"
txyear <- txhousing %>% 
  semi_join(tx9) %>%
  SharedData$new(~year, "Selected years")

p <- ggplot(txyear) +
  geom_line(aes(x = month, y = median, group = year)) +
  facet_wrap(~city, ncol = 3)

p %>%
  ggplotly(tooltip = "year", height = 500, width = 700) %>% 
  highlight(
    "plotly_click", "plotly_doubleclick", defaultValues = "2006",
    dynamic = TRUE, persistent = TRUE, selectize = TRUE
  )