Unified Handling of Graphics Devices

Functions for creating plots and image files in a unified way regardless of output format (EPS, PDF, PNG, SVG, TIFF, WMF, etc.). Default device options as well as scales and aspect ratios are controlled in a uniform way across all device types. Switching output format requires minimal changes in code. This package is ideal for large-scale batch processing, because it will never leave open graphics devices or incomplete image files behind, even on errors or user interrupts.


News

Package: R.devices

Version: 2.15.1 [2016-11-09] o TESTS: Don't test as.architecture() on recordedplot objects that require coercion between endianess, which is yet not supported. o BUG FIX: Calling devNew(type, ..., aspectRatio) with 'type' being a function and neither width nor height could be inferred from the devices type generated an error when trying to generate a warning.

Version: 2.15.0 [2016-11-07] o Printing a plot recorded by capturePlot() now automatically falls back to replaying it coerced to the current machine's architecture if the default replay fails. o Added as.architecture() for recordedplot objects to make it easy to coerce between 32-bit and 64-bit versions of a serialized recorded plot (e.g. via capturePlot()) so that it can be replotted everywhere.

Version: 2.14.0 [2016-03-08] o Added capturePlot() making it possible to capture low-level plot commands using grDevices::recordPlot() such that the plot can be displayed / regenerated elsewhere, e.g. in a different / future R session. Requires R (>= 3.3.0). o BUG FIX: devEval(pdf, ...) without explicit argument 'ext' would give an error. o Package test coverage is 91%.

Version: 2.13.2 [2015-12-16] o Package requires R (>= 2.14.0), because of requireNamespace(). o ROBUSTNESS: Increased package test coverage from 72% to 87%. o BUG FIX: devSetLabel(which, label) gave an error if which was a label. o BUG FIX: Closing devices by their labels gave an error if they where not opened in ordered.

Version: 2.13.1 [2015-09-21] o Add capabilitiesX11(). o Explicit import of 'utils' and 'graphics' functions. o BUG FIX: toX11() gave error "Device type 'X11' is not known/supported". o BUG FIX: devOptions(grDevices::png) returned devOptions("favicon") not devOptions("png").

Version: 2.13.0 [2015-02-21] o ROBUSTNESS/TESTS: Package coverage 74% [was 64%]. o ROBUSTNESS: When calling devEval() on multiple devices then underlying graphics device functions no longer gives an error of unknown arguments, which means it is now possible to pass device specific arguments also when in multi-device calls, e.g. devEval(c("x11", "png"), res=100, { plot(1:10) }). o ROBUSTNESS: devNew("quartz", which="foo") could set the label of device #1(!) when quartz devices was not supported. This was because quartz() only gives a warning (and not an error) when it is not supported, so the internal code thought the devices was succesfully opened. o BUG FIX: Renaming incomplete files gave an error if there were already files renamed for similar reasons. Added package test. o BUG FIX: devEval(type, ...) gave 'Error in strsplit (type, split = "|", fixed = TRUE' if type was a device function. Added package tests showing that it's possible to do devEval(type=grDevices::png, ext="png", plot(1:10)) in addition to devEval(type="png", ext="png", plot(1:10)). o CLEANUP: Using requireNamespace() instead of require() internally.

Version: 2.12.0 [2014-09-17] o DEVICES: Added support for all Cairo* devices of the Cairo package. o DEVICES: Added favicon() device, which is a wrapper for png() with bells and whistles. It has its own device options. Updated toFavicon() to use default argument field="htmlscript", which generates an HTML script that dynamically sets the favicon. o Several functions now supports specifying device type names by regular expressions, e.g. devOptions("cairo_.") and devEval("cairo_.", name="foo", { plot(1:10) }). The latter will output one image file for each available cairo_.* device. o Added support for "global" device options to fall back on if no set for the device type queried, e.g. devOptions("", pointsize=14). o Now arguments 'sep', 'path', 'field' and 'force' for devEval() and the various toNnn() functions now utilizes getDevOption(), which is still backward compatibilty with the old style R options. o Now devIsInteractive() without arguments returns all known interactive devices. o ROBUSTNESS: Now package does a better job of checking whether a particular device is supported on the current system, cf. capabilities() and Cairo::Cairo.capabilities(). o CLEANUP: Dropped argument 'field' for toNnn(), because the default is now NULL which corresponds to returning a DevEvalProduct object. In turn, this object has the pathname as it's value, which was the previous default 'field' value. Also, as.character() on this object returns the (relative) pathname. o CLEANUP: All old-style R options (e.g. 'devEval/args/field') have been deprecated. They will still work for a while but it is recommended to set them as devOptions("", field=...) instead.

Version: 2.11.5 [2014-09-30] o Added view() and !() to DevEvalProduct. o BUG FIX: devDone() would close some devices despite them being on screen/interactive devices, e.g. an x11 device. o BUG FIX: devNew(x11) on Unix/Linux where the default 'width' or 'height' failed to be inferred would throw an error reporting on "cannot coerce type 'closure' to vector of type 'character'".

Version: 2.11.4 [2014-09-16] o ROBUSTNESS: Now withPar() also resets all the graphical parameters available upon entry even if no explicit ones were specified. This covers the case when 'expr' changes the parameters, e.g. withPar({ par(cex=2L); plot(1:10) }). o BUG FIX: Now getPathname(..., relative=FALSE) returns the absolute pathname. o BUG FIX: devOptions() returned the incorrect options for device types "eps", "jpg2" and "png2" if package was not attached.

Version: 2.11.3 [2014-09-12] o Added getDevOption(). o BUG FIX: On Windows, devOptions() assumed that the 'grDevices' package was attached. o BUG FIX: devOptions(type, name=NULL) did not assign the option NULL. o CLEANUP: devDump() fell back on option 'devDump/args/path', but that would never happen. Dropping that option.

Version: 2.11.2 [2014-09-11] o ROBUSTNESS: Added explicit package tests for devOptions(). o BUG FIX: devEval("cairo_pdf", ...) for generate an image file with a *.cairo_pdf filename extension. Now devEval(..., ext=NULL) does a better job of inferring the default extension from the device type.

Version: 2.11.1 [2014-09-02] o Added getData() to DevEvalFileProduct.

Version: 2.11.0 [2014-08-29] o Added support for devEval() to try multiple device types one-by-one until success, e.g. devEval("png|jpg|bmp", ...).

Version: 2.10.0 [2014-08-29] o Changed default argument 'field' for toNNN() from "fullname" to "pathname" as in getOption("devEval/args/field", "pathname"). This should work for most compilers including LaTeX, although for the latter it is preferred to use "fullname". See the package vignette for details. o DOCUMENTATION: Update package vignette with information on how to output image files of multiple formats in one call.

Version: 2.9.3 [2014-08-17] o CLEANUP: Removed false R CMD check NOTE. o Bumped up the package dependencies.

Version: 2.9.2 [2014-05-15] o Bumped up the package dependencies.

Version: 2.9.1 [2014-05-01] o Added withPar() for plotting with temporarily set graphical parameters.

Version: 2.9.0 [2014-04-28] o Added toDefault() for plotting to the default device analogously to how the other toNnn() device functions works. Likewise, added toX11(), toWindows(), toQuartz(), toCairoWin(), toCairoX11(), and toJavaGD() for plotting to interactive/screen devices. o Now it's possible to use devEval() to open a new or activate an existing interactive/screen device. o Added support for (hidden) argument 'which' to devNew(), such that devNew(type, which=which) avoids opening a new device iff an existing device of the same device type and index/label already is opened. For instance, calling devNew("X11", which="foo") will open an X11 device and label it 'foo'. Subsequent calls will set the focus that same device. o BUG FIX: Now devEval("windows", { plot(1:10) }) no longer gives "Error: Detected new graphics devices that was opened but not closed while executing devEval(): '2' (windows)". o Bumped up package dependencies.

Version: 2.8.4 [2014-01-11] o Added asDataURI() for converting an image file to an Base64-encoded data URI character string.

Version: 2.8.3 [2014-01-10] o Added toFavicon() for outputting figures as HTML favicons.

Version: 2.8.2 [2014-01-02] o Now the timestamp of the default path for devDump() is in the current time zone.

Version: 2.8.1 [2013-12-08] o BUG FIX: devOptions(types) would drop all options for combinations of device types that have identical sets of options, e.g. types=c("png", "png") or types=c("bmp", "png"). o CLEANUP: Bumped up package dependencies. No longer need for an ad hoc NAMESPACE import.

Version: 2.8.0 [2013-10-29] o Added devDump() which is short for calling devEval(c("png", "pdf"), ..., which=devList(interactiveOnly=TRUE)), i.e. it copies the content of open interactive ("screen") devices. o Added argument 'interactiveOnly' to devList(). o If 'expr' is missing, devEval() copies the current active device and devEval(which=devList()) copies all open devices. For example, plot(1:10); devEval(c("png", "jpg", "pdf"), name="myfig"). o Now package imports (no longer suggests) the 'base64enc' package. This way packages using 'R.devices' do not have to specify also 'base64enc' if they use dataURI-encoding of images. o ROBUSTNESS/BUG FIX: devSet(which) where 'which' is a very large number could leave lots of stray temporary devices open when error "too many open devices" occurred. Now all temporary devices are guaranteed to be closed also when there is an error. o BUG FIX: devIsOpen(), dev(Get|Set)Label(which) would not handle the case when the device was specified by an numeric 'which' and there is a gap in the device list.

Version: 2.7.3 [2013-10-28] o ROBUSTNESS: Now devSet() is guaranteed to close all temporary devices it opens.

Version: 2.7.2 [2013-10-15] o Now the package vignettes are in vignettes/ and not in inst/doc/, which will not be supported by R (>= 3.1.0). o ROBUSTNESS: Added package system tests for devSet().

Version: 2.7.1 [2013-10-07] o CLEANUP: Now explicitly importing only what is needed in NAMESPACE. o Bumped up package dependencies.

Version: 2.7.0 [2013-09-28] o GENERALIZATION: Vectorized devEval(), e.g. it is now possible to do devEval(c("png", "pdf"), name="MyPlot", { plot(1:10) }). Added arguments 'initially' and 'finally' to devEval(). Contrary to 'expr' which is evaluated for each graphics type/device, these are evaluated only once per call. This makes it possible to avoid repeating expensive computations. o GENERALIZATION: Vectorized devIsInteractive(), devIsOpen(), devGetLabel(), devOff() and devDone(). o Now devOff() and devDone() checks if device is opened before trying to close it. This avoids opening and closing of non-opened devices. o Updated the formal defaults of several devEval() arguments to be NULL. Instead, NULL for such arguments are translated to default internally. This was necessary in order to vectorize devEval(). o Now the 'R.devices' Package object is also available when the package is only loaded (but not attached). o CONSISTENCY: Now devList() returns an empty integer vector (instead of NULL) if no open devices exists. o ROBUSTNESS: The device functions that are not vectorize do now throw an informative error if passed a vector. o ROBUSTNESS: Added several more package system tests. o ROBUSTNESS: Now declaring all S3 method in NAMESPACE. o CLEANUP: Removed fall back attachments of 'R.utils' as these are no longer needed with R.oo (>= 1.15.1).

Version: 2.6.1 [2013-09-17] o ROBUSTNESS: Now getDataURI() throws an Exception is suggested package 'base64enc' is not installed. o BUG FIX: Some package examples and system tests assumed that the suggested package 'base64enc' is installed. o BUG FIX: Package vignette assumed that R.rsp and R.utils are attached. o Bumped up package dependencies.

Version: 2.6.0 [2013-08-29] o Added support for retrieving a Base64-encoded data URI string from a DevEvalFile. o Added classes DevEvalProduct and DevEvalFileProduct, which are returned by devEval(). o ROBUSTNESS: Added package system tests.

Version: 2.5.2 [2013-08-27] o Added devIsInteractive(). o CLEANUP: Package no longer utilizes ':::'. o BUG FIX: Now devEval() no longer passes a pathname to devEval() for interactive devices, which in turn would generate warnings.

Version: 2.5.1 [2013-08-17] o BUG FIX/ROBUSTNESS: Argument 'ext' of devEval() can now be inferred from argument 'type' also when 'type' is passed via a string variable.

Version: 2.5.0 [2013-07-30] o Added support the 'win.metafile' (WMF) device type and added toWMF() creating (extended) WMF files. Since the file format is extended WMF, which often has file extension *.emf, toEMF() was also added. toEMF() uses the same device driver as toWMF() with the only difference that the file extension is *.emf instead of *.wmf. o Now devOptions() can query the options of multiple device types. Added arguments 'options' and 'drop' to devOptions(). o Now devEval() returns a list of class 'DevEvalFile'. o DOCUMENTATION: Hiding internal/legacy functions from the help index.

Version: 2.4.2 [2013-07-15] o Added argument 'sep' to devEval() together with an option to set its default value.

Version: 2.4.1 [2013-07-12] o Updated how vignettes are built and included.

Version: 2.4.0 [2013-07-03] o Now devNew() returns the index of the opened device. o Now devEval() and devNew(), and hence toPNG() and so on, can be called without attaching the package, e.g. R.devices::toPNG(). o CLEANUP: Now package only imports the R.utils. However, it will attach ("load") R.utils as soon as devEval() or devNew() is called. o Bumped up package dependencies.

Version: 2.3.0 [2013-05-30] o Now the package vignette is built via the R (>= 3.0.0) vignette engines, if available.

Version: 2.2.4 [2013-05-20] o CRAN POLICY: Now all Rd \usage{} lines are at most 90 characters long.

Version: 2.2.3 [2013-04-04] o ROBUSTNESS: Now devEval() does a better job of making sure to close the same device as it opened. Previously it would close the current active device, which would not be the correct one if for instance other devices had been open in the meanwhile/in parallel.

Version: 2.2.2 [2013-04-01] o Now package builds with both R.rsp (< 0.9.1) and R.rsp (>= 0.9.1).

Version: 2.2.1 [2013-03-28] o Bumped up package dependencies. o Cleaned up the NAMESPACE file.

Version: 2.2.0 [2013-03-07] o DOCUMENTATION: Preparing package vignettes for the upcoming R 3.0.0 support for non-Sweave vignettes. o Bumped up package dependencies.

Version: 2.1.6 [2013-02-13] o Changed default argument 'field' for devEval() from NULL to getOption("devEval/args/field", NULL). o Changed default argument 'field' for toNnn() from "fullname" to getOption("devEval/args/field", "fullname").

Version: 2.1.5 [2013-02-13] o Specifying new DESCRIPTION field 'VignetteBuilder'.

Version: 2.1.4 [2012-12-19] o Utilizing new startupMessage() of R.oo.

Version: 2.1.3 [2012-11-19] o DOCUMENTATION: Minor corrections and clarifications in the vignette. o CONSISTENCY: Now using throw() instead of stop() everywhere. o CLEANUP: Only importing what is necessary from R.methodsS3 and R.oo. o CLEANUP: Made all integer constants truly integers.

Version: 2.1.2 [2012-08-21] o DOCUMENTATION: Fixed minor typo in the vignette. o DOCUMENTATION: In help(devEval) the link to help(devNew) was broken. o Updated versions of the package dependencies.

Version: 2.1.1 [2012-05-01] o Now devOptions() returns options invisibly if some options were set, otherwise not, e.g. devOptions() versus devOptions("png", width=1024). o Added a first draft of a package vignette.

Version: 2.1.0 [2012-04-27] o Merged updates from the R.utils v1.13.1.

Version: 2.0.0 [2011-11-05] o Created package by extracting all methods in R.utils v1.9.1 that are related to graphical devices. o The below change log shows the changes to the device methods while they were in R.utils. For this reason, we choose to set the version of this package such that it starts where we left R.utils.

Version: 1.9.1 [2011-11-05] o Added devOptions(). o Added default 'width' and 'height' values to eps(). o Turned png2() and jpeg2() into plain functions without a generic. This is consistent with how eps() is defined. o GENERALIZATION: Now the default 'width' is inferred from devOptions() if needed. o DOCUMENTATION: Added an example to help(devEval).

Version: 1.8.6 [2011-10-31] o Added argument 'field' to devEval().

Version: 1.8.2 [2011-09-24] o devNew() no longer gives a warning about argument 'aspectRatio' is specified when both or neither of 'width' and 'height' are given, and 'aspectRatio' is 1.

Version: 1.7.5 [2011-04-12] o Now devEval("jpg", ...) is recognized as devEval("jpeg", ...).

Version: 1.7.3 [2011-04-02] o Now argument 'force' of devEval() defaults to getOption("devEval/args/force", TRUE).

Version: 1.7.2 [2011-03-18] o Now argument 'path' of devEval() defaults to getOption("devEval/args/path", "figures/"). o Now devEval() does a better job of "cleaning up" 'name' and 'tags'.

Version: 1.7.1 [2011-03-18] o devNew() gained option 'devNew/args/par', which can be used to specify the default graphical parameters for devNew(). Any additional parameters passed via argument 'par' will override such default ones, if both specifies the same parameter. o The automatic archiving of devEval() is not considered unless the R.archive package is loaded, regardless of option settings. o DOCUMENTATION: The title of help(devDone) was incorrect.

Version: 1.7.0 [2011-03-10] o Now argument 'aspectRatio' of devNew() defaults to 1 (not NULL). o REPRODUCIBLE RESEARCH: Now devEval() archives any generated image files if R.archive option 'devEval' is TRUE.

Version: 1.6.3 [2011-02-20] o Added argument 'par' to devNew() for applying graphical parameters at the same time as the device is opened, which is especially useful when using devEval(). o Changed argument 'force' of devEval() to default to TRUE.

Version: 1.6.2 [2011-02-14] o Added trial version of devEval() for simple creation of images. o Added argument 'aspectRatio' to devNew(), which updates/sets the 'height' or the 'width', if the one of the other is not given.

Version: 1.5.5 [2010-10-26] o Now argument 'which' to devSet() can be any object. If not a single numeric or a single character string, then a checksum character string is generated using digest::digest(which).

Version: 1.0.8 [2008-10-16] o Now devDone(which=1) does nothing. Before it gave an error. o BUG FIX: Argument 'type' of devNew() did not take function:s.

Version: 1.0.6 [2008-09-08] o Now devNew() filters out arguments 'file' and 'filename' if the device is interactive.

Version: 1.0.4 [2008-08-01] o Added several functions for extending the current functions dealing with devices. All added functions can address a device by a label in addition to the standard device index. The devGetLabel() and devSetLabel() gets and sets the label of a give device. devList() lists the indices of existing device named by their labels, cf. dev.list(). The functions devSet() and devOff() work like dev.set() and dev.off() but accept labels as well. Furthermore, devSet(idx) will open a device with index 'idx' if it does not exists, and devSet(label) a device with that label if not already opened. The devIsOpen() checks if a device is open or not. The devDone() function calls devOff() except for screen devices.

Version: 1.0.0 [2008-02-26] o The default filename for eps() had extension *.ps not *.eps.

Version: 0.7.6 [2006-02-15] o Since the png2() and jpeg2() devices are in this package, the eps() device from R.graphics has been moved here for consistency.

Version: 0.6.0 [2005-09-24] o Added trial versions of jpeg2() and png2().

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("R.devices")

2.16.0 by Henrik Bengtsson, 3 months ago


https://github.com/HenrikBengtsson/R.devices


Report a bug at https://github.com/HenrikBengtsson/R.devices/issues


Browse source code at https://github.com/cran/R.devices


Authors: Henrik Bengtsson [aut, cre, cph]


Documentation:   PDF Manual  


LGPL (>= 2.1) license


Imports grDevices, R.methodsS3, R.oo, R.utils, base64enc

Suggests digest, Cairo, R.rsp


Imported by aroma.affymetrix, inpdfr.

Depended on by aroma.core.

Suggested by PSCBS, R.rsp, babel, matrixStats.


See at CRAN