Checks if zero or more devices are open or not.

devIsOpen(which=dev.cur(), ...)

Arguments

which

An index (numeric) vector or a label (character) vector.

...

Not used.

Value

Returns a named logical

vector with TRUE if a device is open, otherwise FALSE.

Author

Henrik Bengtsson

Examples

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Use devices for conditional processing of code. 
# Close devices to rerun code.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Currently opened device:\n")
#> Currently opened device:
print(devList())
#> Device 2 
#>        2 

# Alt A: Use device index counter (starting with the 16:th)
fig <- 15
if (!devIsOpen(fig <- fig + 1)) {
  devSet(fig)
  cat("Figure", fig, "\n")
  plot(1:10)
}
#> Error in devOptions(type): Device type ‘<function>’ is not known/supported on this operating system/platform. Supported device types are: ‘bmp’, ‘cairo_pdf’, ‘cairo_ps’, ‘CairoPDF’, ‘CairoPNG’, ‘CairoPS’, ‘CairoSVG’, ‘CairoX11’, ‘eps’, ‘favicon’, ‘jpeg’, ‘jpeg2’, ‘nulldev’, ‘pdf’, ‘pictex’, ‘png’, ‘png2’, ‘postscript’, ‘quartz’, ‘svg’, ‘tiff’, ‘x11’, ‘X11’, ‘xfig’
cat("Currently opened device:\n")
#> Currently opened device:
print(devList())
#> Device 2 
#>        2 

if (!devIsOpen(fig <- fig + 1)) {
  devSet(fig)
  cat("Figure", fig, "\n")
  plot(1:10)
}
#> Error in devOptions(type): Device type ‘<function>’ is not known/supported on this operating system/platform. Supported device types are: ‘bmp’, ‘cairo_pdf’, ‘cairo_ps’, ‘CairoPDF’, ‘CairoPNG’, ‘CairoPS’, ‘CairoSVG’, ‘CairoX11’, ‘eps’, ‘favicon’, ‘jpeg’, ‘jpeg2’, ‘nulldev’, ‘pdf’, ‘pictex’, ‘png’, ‘png2’, ‘postscript’, ‘quartz’, ‘svg’, ‘tiff’, ‘x11’, ‘X11’, ‘xfig’
cat("Currently opened device:\n")
#> Currently opened device:
print(devList())
#> Device 2 
#>        2 

# Alt B: Use device labels
if (!devIsOpen(label <- "part 1")) {
  devSet(label)
  cat("Part 1\n")
  plot(1:10)
}
#> Error in devOptions(type): Device type ‘<function>’ is not known/supported on this operating system/platform. Supported device types are: ‘bmp’, ‘cairo_pdf’, ‘cairo_ps’, ‘CairoPDF’, ‘CairoPNG’, ‘CairoPS’, ‘CairoSVG’, ‘CairoX11’, ‘eps’, ‘favicon’, ‘jpeg’, ‘jpeg2’, ‘nulldev’, ‘pdf’, ‘pictex’, ‘png’, ‘png2’, ‘postscript’, ‘quartz’, ‘svg’, ‘tiff’, ‘x11’, ‘X11’, ‘xfig’
cat("Currently opened device:\n")
#> Currently opened device:
print(devList())
#> Device 2 
#>        2 


if (!devIsOpen(label <- "part 2")) {
  devSet(label)
  cat("Part 2\n")
  plot(1:10)
}
#> Error in devOptions(type): Device type ‘<function>’ is not known/supported on this operating system/platform. Supported device types are: ‘bmp’, ‘cairo_pdf’, ‘cairo_ps’, ‘CairoPDF’, ‘CairoPNG’, ‘CairoPS’, ‘CairoSVG’, ‘CairoX11’, ‘eps’, ‘favicon’, ‘jpeg’, ‘jpeg2’, ‘nulldev’, ‘pdf’, ‘pictex’, ‘png’, ‘png2’, ‘postscript’, ‘quartz’, ‘svg’, ‘tiff’, ‘x11’, ‘X11’, ‘xfig’
cat("Currently opened device:\n")
#> Currently opened device:
print(devList())
#> Device 2 
#>        2