r - How to use fig.show=animate in knitr without administrator privileges -
i use windows without administrator privileges hence cannot set path in windows path variable.
the ffmpeg.exe file in "u:/programfiles/imagemagick-6.8.5-5/" folder.
i have found how use savevideo() function of animate package:
ani.options(ffmpeg = shquote('u:/programfiles/imagemagick-6.8.5-5/ffmpeg.exe')) savevideo({ par(mar = rep(3, 4)) (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() } }, video.name="mavideo.mp4", outdir="u:/data/rtests/animation") but haven't find how knit rmd file option fig.show=animate in chunk, instance:
```{r clock, fig.width=7, fig.height=6, fig.show='animate'} par(mar = rep(3, 4)) (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() } ``` i have tried modifiy hook_ffmpeg_html() function changing ffmpeg.cmd variable:
```{r} hook_ffmpeg_html2 <- function (x, options) { ........ ffmpeg.cmd = paste("-y", "-r", 1/options$interval, "-i", fig.fname, mov.fname) ffmpeg.cmd <- paste('"u:/programfiles/imagemagick-6.8.5-5/ffmpeg"', ffmpeg.cmd) ...... } opts_knit$set(animation.fun = hook_ffmpeg_html2) ``` but chunk not work, below error message :
label: unnamed-chunk-1 warning in block_exec(params) : failed tidy r code in chunk <unnamed-chunk-1> reason: error in base::parse(text = text, srcfile = null) : 21:14: unexpected symbol 20: options$out.height), if ("controls" %in% mov.opts) 21: "controls=\\"controls
(am transferring comments answer.)
you don't need admin privs set path current process r. sys.setenv(path = "...") it.
Comments
Post a Comment