Learn R Programming

R.utils (version 1.9.7)

devEval: Opens a new device, evaluate (graphing) code, and closes device

Description

Opens a new device, evaluate (graphing) code, and closes device.

Usage

devEval(type=getOption("device"), expr, envir=parent.frame(), name="Rplot", tags=NULL, ..., ext=substitute(type), filename=sprintf("%s.%s", paste(c(name, tags), collapse = ","), ext), path=getOption("devEval/args/path", "figures/"), field=NULL, force=getOption("devEval/args/force", TRUE))

Arguments

type
Specifies the type of device to be used by devNew.
expr
The expression of graphing commands to be evaluated.
envir
The environment where expr should be evaluated.
name, tags
The fullname name of the image is specified as the name with optional comma-separated tags appended.
ext
The filename extension of the image file generated, if any. By default, it is inferred from argument type.
...
Additional arguments passed to devNew.
filename
The filename of the image saved, if any. See also below.
path
The directory where then image should be saved, if any.
field
An optional character string specifying a specific field of the named result list to be returned.
force
If TRUE, and the image file already exists, then it is overwritten, otherwise not.

Value

  • Returns a named list with items specifying for instance the pathname, the fullname etc of the generated image. If argument field is given, then the value of the corresponding element is returned. Note that the return value may be changed in future releases.

Generated image file

If created, the generated image file is saved in the directory specfied by argument path with a filename consisting of the name followed by optional comma-separated tags and a filename extension given by argument ext.

See Also

To change default device parameters such as the width or the height, devOptions(). devNew().

Examples

Run this code
res <- devEval("png", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
  plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.png"

res <- devEval("pdf", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
  plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.pdf"

res <- devEval("eps", name="MyPlot", tags=c("10", "rnd"), aspectRatio=0.7, {
  plot(1:10)
})
print(res$pathname)
# [1] "figures/MyPlot,10,rnd.eps"

Run the code above in your browser using DataLab