devIsOpen

0th

Percentile

Checks if a device is open or not

Checks if a device is open or not.

Keywords
utilities, device
Usage
devIsOpen(which=dev.cur(), ...)
Arguments
which
An index (numeric) or a label (character).
...
Not used.
Value

  • Returns TRUE if the device is open, otherwise FALSE.

Aliases
  • devIsOpen
Examples
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Use devices for conditional processing of code. 
# Close devices to rerun code.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Currently opened device:
")
print(devList())

# Alt A: Use device index counter (starting with the 16:th)
fig <- 15
if (!devIsOpen(fig <- fig + 1)) {
  devSet(fig)
  cat("Figure", fig, "")
  plot(1:10)
}
cat("Currently opened device:
")
print(devList())

if (!devIsOpen(fig <- fig + 1)) {
  devSet(fig)
  cat("Figure", fig, "")
  plot(1:10)
}
cat("Currently opened device:
")
print(devList())

# Alt B: Use device labels
if (!devIsOpen(label <- "part 1")) {
  devSet(label)
  cat("Part 1
")
  plot(1:10)
}
cat("Currently opened device:
")
print(devList())


if (!devIsOpen(label <- "part 2")) {
  devSet(label)
  cat("Part 2
")
  plot(1:10)
}
cat("Currently opened device:
")
print(devList())
Documentation reproduced from package R.utils, version 1.6.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.