dygraphs for R

The {dygraphs} package is an R interface to the dygraphs JavaScript charting library. It provides rich facilities for charting time-series data in R, including:

Installation

You can install this package from CRAN, or the development version from GitHub:

# CRAN version
install.packages('dygraphs')

# Or Github version
if (!require('remotes')) install.packages('remotes')
# remotes::install_github('rstudio/dygraphs')
install.packages("dygraphs", repos = c('https://rstudio.r-universe.dev', 'https://cloud.r-project.org'))

Usage

If you have an xts-compatible time-series object creating an interactive plot of it is as simple as this:

dygraph(nhtemp, main = "New Haven Temperatures")

You can also further customize axes and series display as well as add interactive features like a range selector:

dygraph(nhtemp, main = "New Haven Temperatures") %>%
  dyAxis("y", label = "Temp (F)", valueRange = c(40, 60)) %>%
  dyOptions(fillGraph = TRUE, drawGrid = FALSE) %>%
  dyRangeSelector()

See the online documentation for the {dygraphs} package for additional details and examples.