moderndive / ModernDive_book

Statistical Inference via Data Science: A ModernDive into R and the Tidyverse

Home Page:https://www.moderndive.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Appendix C - Interactive Plot

gungorMetehan opened this issue · comments

Does the interactive plot code work properly (HTML)?

App_C

Hmm, it does appear to be broken. We'll need to look into this.

This doesn't seem to work in the Viewer in RStudio either currently.

Looks like it just needed a conversion to a data frame. I'll get this updated now:

library(dygraphs)
library(nycflights13)
flights_day <- mutate(flights, date = as.Date(time_hour))
flights_summarized <- flights_day %>%
  group_by(date) %>%
  summarize(median_arr_delay = median(arr_delay, na.rm = TRUE)) %>%
  as.data.frame()
rownames(flights_summarized) <- flights_summarized$date
flights_summarized <- select(flights_summarized, -date)
dyRangeSelector(dygraph(flights_summarized))