dev2swf {R2SWF} | R Documentation |
Convert R graphics to SWF using different graphics devices
Description
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.
Usage
dev2swf(
expr,
output = "movie.swf",
bgColor = "white",
interval = 1,
dev = "png",
file.ext = "png",
img.name = "Rplot",
...
)
Arguments
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 |
Details
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.
Value
The name of the generated swf file if succeeded.
Author(s)
Yihui Xie <https://yihui.org>
Examples
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)