R.devices 2.16.0 - Unified Handling of Graphics Devices - is on CRAN. With this release, you can now easily suppress unwanted graphics, e.g. graphics produced by one of those do-everything-in-one-call functions that we all bump into once in a while. To suppress graphics, the R.devices package provides graphics device nulldev(), and function suppressGraphics(), which both send any produced graphics into the void. This works on all operating systems, including Windows.
Guillaume Nery base jumping at Dean’s Blue Hole, filmed on breath hold by Julie Gautier
Examples
library(R.devices)
nulldev()
plot(1:100, main = &quot;Some Ignored Graphics&quot;)
dev.off()
R.devices::suppressGraphics({
plot(1:100, main = &quot;Some Ignored Graphics&quot;)
})
Other Features
Some other reasons for using the R.devices package:
No need to call dev.off() - Did you ever forgot to call dev.off(), or did a function call produce an error causing dev.off() not to be reached, leaving a graphics device open? By using one of the toPDF(), toPNG(), … functions, or the more general devEval() function, dev.off() is automatically taken care of.
No need to specify filename extension - Did you ever switch from using png() to, say, pdf(), and forgot to update the filename resulting in a my_plot.png file that is actually a PDF file? By using one of the toPDF(), toPNG(), … functions, or the more general devEval() function, filename extensions are automatically taken care of - just specify the part without the extension.
Specify the aspect ratio - rather than having to manually calculate device-specific arguments width or height, e.g. toPNG(&quot;my_plot&quot;, { plot(1:10) }, aspectRatio = 2/3). This is particularly useful when switching between device types, or when outputting to multiple ones at the same time.
Unified API for graphics options - conveniently set (most) graphics options including those that can otherwise only be controlled via arguments, e.g. devOptions(&quot;png&quot;, width = 1024).
Control where figure files are saved - the default is folder figures/ but can be set per device type or globally, e.g. devOptions(&quot;*&quot;, path = &quot;figures/col/&quot;).
Easily produce EPS and favicons - toEPS() and toFavicon() are friendly wrappers for producing EPS and favicon graphics.
Capture and replay graphics - for instance, use future::plan(remote, workers = &quot;remote.server.org&quot;); p %