Site icon R-bloggers

R.devices – Into the Void

[This article was first published on JottR on R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 < !-- GIF from https://blog.francetvinfo.fr/l-instit-humeurs/2013/09/01/vis-ma-vie-dinstit-en-gif-anime-9.html -->

Examples

library(R.devices)
nulldev()
plot(1:100, main = "Some Ignored Graphics")
dev.off()

R.devices::suppressGraphics({
  plot(1:100, main = "Some Ignored Graphics")
})

Other Features

Some other reasons for using the R.devices package:

Some more examples

R.devices::toPDF("my_plot", {
  plot(1:100, main = "Amazing Graphics")
})
### [1] "figures/my_plot.pdf"

R.devices::toPNG("my_plot", {
  plot(1:100, main = "Amazing Graphics")
})
### [1] "figures/my_plot.png"

R.devices::toEPS("my_plot", {
  plot(1:100, main = "Amazing Graphics")
})
### [1] "figures/my_plot.eps"

R.devices::devEval(c("png", "pdf", "eps"), name = "my_plot", {
  plot(1:100, main = "Amazing Graphics")
}, aspectRatio = 1.3)
### $png
### [1] "figures/my_plot.png"
### 
### $pdf
### [1] "figures/my_plot.pdf"
### 
### $eps
### [1] "figures/my_plot.eps"

Links

See also

To leave a comment for the author, please follow the link and comment on their blog: JottR on R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.