
Evaluate plotting expression with standardized graphics device management
with_device.RdInternal helper to evaluate a graphics expression either on the current active
device (device = "active") or redirected to a standardized output file in
dir_output (PDF, PNG, JPEG, or SVG).
Arguments
- expr
An expression or code block to evaluate within the device context.
- device
Character scalar specifying the output graphics device:
"active"(default, active screen/R device),"pdf","png","jpg","jpeg", or"svg".- dir_output
Character scalar, destination directory for exported files (defaults to
tempdir()). Ignored whendevice = "active".- case
Optional character scalar, case study name identifier.
- project
Optional character scalar, project name identifier.
- graphic
Optional character scalar, graphic type or identifier.
- lang
Character scalar, ISO 639-1 language code (defaults to
"en").- width
Numeric scalar, width of the output device in inches (default is 5.8).
- height
Numeric scalar, height of the output device in inches (default is 4).
- pointsize
Numeric scalar, base point size of plotted text (default is 10).
- res
Numeric scalar, resolution in dpi for raster devices (PNG/JPEG, default is 300).
Value
An invisible character scalar giving the path of the generated file
when device != "active", or invisible NULL when device = "active".
Details
When device != "active", the output file name is automatically constructed
by joining non-empty identifiers:
<case>-<project>-<graphic>-<lang>.<device>.
The destination directory dir_output is created if necessary, and the
appropriate graphics device is opened with dimensions width and height in
inches, base font size pointsize, and resolution res (for PNG and JPEG).
On function exit, dev.off() is automatically closed.
When device = "active", the expression is evaluated directly on the current
graphics device without opening or closing any file device.
Author
Frédéric Grelot, frederic.grelot.1994_cran@m4x.org