dev2swf | R Documentation |
Given an R expression that can produce a sequence of images, this function
will record the images with the device provided (e.g.
png()
or jpeg()
) and
convert them to a Flash file.
dev2swf( expr, output = "movie.swf", bgColor = "white", interval = 1, dev = "png", file.ext = "png", img.name = "Rplot", ... )
expr |
an expression to generate a sequence of images |
output |
the name of the output swf file |
bgColor |
background color of the output SWF file |
interval |
the time interval between animation frames |
dev |
the name of the graphics device to use (e.g. |
file.ext |
the file extension for the images |
img.name |
the file name of the images without the extension |
... |
other arguments to be passed to the graphics device |
You can also use devices which are not in the grDevices package by
setting the dev
argument to the name of the function that opens a
device, e.g. CairoPNG()
in the Cairo package. Note
that the file.ext
argument should be set accordingly.
The name of the generated swf file if succeeded.
Yihui Xie <https://yihui.org>
olddir = setwd(tempdir()) output1 = dev2swf({ for(i in 1:10) plot(runif(20), ylim = c(0, 1)) }, dev='png', file.ext='png', output='movie-png.swf') swf2html(output1) if(capabilities("cairo")) { output2 = dev2swf({ for(i in 1:10) plot(runif(20), ylim = c(0, 1)) }, dev='svg', file.ext='svg', output='movie-svg.swf') swf2html(output2) } setwd(olddir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.