devEval {R.devices} | R Documentation |
Opens a new graphics device, evaluate (graphing) code, and closes device
Description
Opens a new graphics device, evaluate (graphing) code, and closes device.
Usage
devEval(type=getOption("device"), expr, initially=NULL, finally=NULL,
envir=parent.frame(), name=NULL, tags=NULL, sep=getDevOption(type, "sep",
default = ","), ..., ext=NULL, filename=NULL, path=getDevOption(type, "path",
default = "figures"), field=getDevOption(type, name = "field"),
onIncomplete=c("remove", "rename", "keep"), force=getDevOption(type, "force",
default = TRUE), which=dev.cur(), .exprAsIs=FALSE, .allowUnknownArgs=FALSE)
Arguments
type |
Specifies the type of graphics device to be used.
The device is created and opened using |
expr |
The |
initially , finally |
Optional |
envir |
The |
name , tags , sep |
The fullname name of the image is specified
as the name with optional |
ext |
The filename extension of the image file generated, if any.
By default, it is inferred from argument |
... |
Additional arguments passed to |
filename |
The filename of the image saved, if any.
By default, it is composed of arguments |
path |
The directory where then image should be saved, if any. |
field |
An optional |
onIncomplete |
A |
force |
If |
which |
A |
.exprAsIs , .allowUnknownArgs |
(Internal use only). |
Value
Returns a DevEvalFileProduct
if the device generated an
image file, otherwise an DevEvalProduct
.
If argument field
is given, then the field of the
DevEvalProduct
is returned instead.
Note that the default return value may be changed in future releases.
Generated image file
If created, the generated image file is saved in the directory
specified by argument path
with a filename consisting of
the name
followed by optional comma-separated tags
and a filename extension given by argument ext
.
By default, the image file is only created if the expr
is evaluated completely. If it is, for instance, interrupted
by the user or due to an error, then any incomplete/blank image
file that was created will be removed. This behavior can be
turned of using argument onIncomplete
.
Author(s)
Henrik Bengtsson
See Also
To change default device parameters such as the width or the height,
devOptions
().
devNew
().
Examples
# Plot to PNG using one whatever PNG device driver is available
res <- devEval("{png}", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.png"
str(res$dataURI)
# chr "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAA..."
## Plot to PDF using grDevices::pdf()
res <- devEval("pdf", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.pdf"
## Plot to EPS using R.devices::eps()
res <- devEval("eps", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.eps"