# 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()
Run the code above in your browser using DataLab