简体   繁体   中英

Combining R Markdown and Animation Package

Is there a way to combine animation package and r markdown? I want to generate animation which i want to include and describe in html file generated from r markdown.

Of course I can embed code from saveHTML or saveGIF file in already generated r markdown file, but i want to automate this process.

I'm working on Windows, R 15.1 and the last RStudio.

Here is the clock example from the knitr graphics manual (see comment on your question) in markdown:

```{r clock, fig.width=7, fig.height=6, fig.show='animate'}
par(mar = rep(3, 4))
for (i in seq(pi/2, -4/3 * pi, length = 12)) {
    plot(0, 0, pch = 20, ann = FALSE, axes = FALSE)
    arrows(0, 0, cos(i), sin(i))
    axis(1, 0, "VI"); axis(2, 0, "IX")
    axis(3, 0, "XII"); axis(4, 0, "III"); box()
}
```

You need to have the ffmpeg executable in your path for it to work. Knitr will use the animation package, which in turn will call ffmpeg to generate an mp4 file which is embedded in your html output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM