Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 286
Maciej Avatar asked Aug 20 '12 13:08

Maciej


People also ask

Can R Markdown be interactive?

If you include an interactive element in a static output format, like a PDF, R Markdown will embed a screenshot of the element. Learn more about interactive documents with R Markdown at Interactive Documents.

What is the difference between Markdown and R Markdown?

R Markdown is an extension of the markdown syntax. R Markdown files are plain text files that typically have the file extension . Rmd . They are written using an extension of markdown syntax that enables R code to be embedded in them in a way which can later be executed.

What can R Markdown be converted into?

Convert R Markdown documents into a variety of formats including HTML, MS Word, PDF, and Beamer.

What is the difference between RStudio and R Markdown?

To put it simply - R is the actual programming language, RStudio is a convenient interface in which to use it, and R Markdown is a specific type of file format designed to produce documents that include both code and text.


1 Answers

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.

like image 182
ROLO Avatar answered Sep 20 '22 13:09

ROLO