dev.off(which) can be used to close a specific graphics device where "which" is the index of the device, but is there a way to assign a custom number (or name) to a windows device so that specific window can be later closed via dev.off (or some other method) if it is open?
The following does NOT work. The target device is not open when its dev.off is called, and another window that later got assigned the original index associated with the target device is closed instead. plot(0,0,type='n') # target window to close text(0,0,"close me") targetindex<-dev.cur() # unbeknownst to the programmer, user closes device by clicking the red "X" or... dev.off() # user draws a new graph that he wants to keep open plot(1,1,type='n') text(1,1,"do not close me") # now it's time for the program to close the original graphics device (if it still happens to be open) dev.off(targetindex) # the wrong device has been closed because the original window had closed and the index associated with original graph is now associated with something else ---- I'm looking for something like: dev.off(which = "original figure") or dev.off(which = n), where n is a custom index (like 10000) that will not be later assigned to a different device [unless explicitly assigned that index]. Any help would be greatly appreciated. Thanks! -- Dan Dalthorp, PhD USGS Forest and Rangeland Ecosystem Science Center Forest Sciences Lab, Rm 189 3200 SW Jefferson Way Corvallis, OR 97331 ph: 541-750-0953 ddalth...@usgs.gov [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.