safe.dev.off {rgl} | R Documentation |
Close graphics device in a safe way.
Description
The dev.off
function in grDevices doesn't restore
the previous graphics device when called. This function does.
Usage
safe.dev.off(which = dev.cur(), prev = dev.prev())
Arguments
which |
Which device to close. |
prev |
Which device to set as current after closing. |
Details
This function closes device which
if it is not device 1,
then calls dev.set(prev)
if there are any devices still
open.
Value
The number and name of the new active device. It will not
necessarily be prev
if that device isn't already open.
Author(s)
Duncan Murdoch
References
https://bugs.r-project.org/show_bug.cgi?id=18604
Examples
# Open a graphics device
dev.new()
first <- dev.cur()
# Open a second graphics device
dev.new()
second <- dev.cur()
second
# Open another one, and close it using dev.off()
dev.new()
dev.off()
dev.cur() == second # Not the same as second!
# Try again with safe.dev.off()
dev.set(second)
dev.new()
safe.dev.off()
dev.cur() == second
# Close the other two devs
safe.dev.off()
safe.dev.off()
[Package rgl version 1.3.1 Index]