| safe.dev.off | R Documentation |
The dev.off function in grDevices doesn't restore
the previous graphics device when called. This function does.
safe.dev.off(which = dev.cur(), prev = dev.prev())
which |
Which device to close. |
prev |
Which device to set as current after closing. |
This function closes device which if it is not device 1,
then calls dev.set(prev) if there are any devices still
open.
The number and name of the new active device. It will not
necessarily be prev if that device isn't already open.
Duncan Murdoch
https://bugs.r-project.org/show_bug.cgi?id=18604
# 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()