I am creating an html document from an rmarkdown file using knitr and inserting an animation code chunk as follows:
```{r,fig.show='animate'}
for(i in 1:10) plot(rnorm(10))
```
The animation is created just fine, however, I haven't found a way to speed up the animation. For instance, the animation package has the interval
argument for saveGIF()
which allows one to speed up or slow down a gif. Any suggestions are welcome!
If you prefer to use the console by default for all your R Markdown documents (restoring the behavior in previous versions of RStudio), you can make Chunk Output in Console the default: Tools -> Options -> R Markdown -> Show output inline for all R Markdown documents .
The fig. retina argument is a dpi multiplier for displaying HTML output on retina screens and changes the chunk option dpi to dpi * fig.
If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it.
eval TRUE If FALSE, knitr will not run the code in the code chunk. include TRUE If FALSE, knitr will run the chunk but not include the chunk in the final document. purl TRUE If FALSE, knitr will not include the chunk when running purl() to extract the source code.
The chunk option interval
lets you set frame duration, while the aniopts
option lets you pass in a string containing options that are passed directly on to the LaTeX package animate. (Both are documented in the "Animation" section of the knitr package's options documentation)
So, for instance, to speed the animation up 5-fold and provide it with controls but no looping, do this:
```{r, fig.show='animate', interval=0.2, aniopts="controls"}
for(i in 1:10) plot(rnorm(10))
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With