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.