File: Sweave_animation.R

package info (click to toggle)
r-cran-animation 2.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,268 kB
  • sloc: javascript: 873; sh: 15; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## demo on how to insert animations in Sweave

## copy the Rnw file to temp dir
file.copy(system.file('misc', 'Sweave_animation.Rnw', package = 'animation'), tempdir())

owd = setwd(tempdir())

## run Sweave
Sweave('Sweave_animation.Rnw')


## this may not be necessary, if you have the LaTeX package 'animate' installed
file.copy(system.file('misc', 'animate', 'animate.sty', package = 'animation'),
          'animate.sty', overwrite = TRUE)
file.copy(system.file('misc', 'animate', 'animfp.sty', package = 'animation'),
          'animfp.sty', overwrite = TRUE)

## compile the tex document: it may take a while
tools::texi2dvi('Sweave_animation.tex', pdf = TRUE)

system(sprintf('%s %s', shQuote(normalizePath(getOption('pdfviewer'))),
               'Sweave_animation.pdf'))

setwd(owd)