Learn R Programming

animate (version 0.3.9.4)

insert_animate: Insert an animated plot into an R Markdown document

Description

Insert an animated plot into an R Markdown document

Usage

insert_animate(file, options = click_to_play(), style, use_cdn = TRUE)

Arguments

file

The exported plot.

options

A character string; the JavaScript to customise the playback options. Two basic options click_to_play() and click_to_loop() have been implemented for general usage.

style

Optional style for the iframe that hosts the visualisation.

use_cdn

TRUE / FALSE; if TRUE, serve the assets from a CDN, otherwise embed the assets into the HTML.

Examples

Run this code
# \donttest{
input <- tempfile(fileext = ".Rmd")
output <- tempfile(fileext = ".html")
writeLines('
```{r, echo = FALSE, message = FALSE}
# Run / include the following in a code chunk of an R Markdown document
library(animate)
insert_animate(system.file("tests/Lorenz_system.json.gz", package = "animate"),
               options = click_to_loop())
```
', input)
knitr::knit(input, output)
# browseURL(output)
# }

Run the code above in your browser using DataLab