R Under development (unstable) (2025-12-16 r89184 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > message("*** devNew() ...") *** devNew() ... > > library("R.devices") R.devices v2.17.3 successfully loaded. See ?R.devices for help. > > > message("*** devNew(which=which) ...") *** devNew(which=which) ... > > idx <- devNew() > plot(1:10) > idx2 <- devNew(which=idx) > plot(1:10) > devOff(idx2) pdf 2 > if (idx2 != idx) devOff(idx) null device 1 > > message("*** devNew(which=which) ... DONE") *** devNew(which=which) ... DONE > > > message("*** devNew(aspectRatio) ...") *** devNew(aspectRatio) ... > ## Height is inferred > devNew(width=10, aspectRatio=1.5) > plot(1:10) > devOff() null device 1 > > ## Width is inferred > devNew(height=10, aspectRatio=1.5) > plot(1:10) > devOff() null device 1 > message("*** devNew(aspectRatio) ... DONE") *** devNew(aspectRatio) ... DONE > > > message("*** devNew(scale) ...") *** devNew(scale) ... > > devNew(width=10, scale=1.5) > plot(1:10) > devOff() null device 1 > > devNew(height=10, scale=1.5) > plot(1:10) > devOff() null device 1 > > ## Force 'width' from device options > devNew(aspectRatio=NULL, scale=1.5) > plot(1:10) > devOff() null device 1 > > message("*** devNew(scale) ... DONE") *** devNew(scale) ... DONE > > > message("*** devNew() - warnings ...") *** devNew() - warnings ... > > ok <- tryCatch({ + devNew(width=10, height=10, aspectRatio=1.5) + FALSE + }, warning = function(warn) { + print(warn) + TRUE + }) > stopifnot(ok) > > res <- try(devNew(par=list(1))) Error in devNew(par = list(1)) : Argument 'par' has to be a named list: list > stopifnot(inherits(res, "try-error")) > > message("*** devNew() - warnings ... DONE") *** devNew() - warnings ... DONE > > > message("*** devNew() - errors ...") *** devNew() - errors ... > > res <- try(devNew(par=c(pch=1))) Error in devNew(par = c(pch = 1)) : Argument 'par' has to be a named list: numeric > stopifnot(inherits(res, "try-error")) > > res <- try(devNew(par=list(1))) Error in devNew(par = list(1)) : Argument 'par' has to be a named list: list > stopifnot(inherits(res, "try-error")) > > devNew(label="foo") > plot(1:10) > res <- try(devNew(label="foo")) Error in devNew(label = "foo") : Cannot open device. Label is already used: foo > stopifnot(inherits(res, "try-error")) > devOff() null device 1 > > message("*** devNew() - errors ... DONE") *** devNew() - errors ... DONE > > message("*** devOff() ... ") *** devOff() ... > > ## Open and close device > idx0 <- devNew() > idx1 <- devOff(idx0) > str(idx1) Named int 1 - attr(*, "names")= chr "null device" > > ## Close same device again (should silently return) > idx2 <- devOff(idx0) > str(idx2) Named int 1 - attr(*, "names")= chr "null device" > > stopifnot(identical(idx2, idx1)) > > ## Close many devices > idx3 <- devOff(2:5) > str(idx3) Named int 1 - attr(*, "names")= chr "null device" > > message("*** devOff() ... DONE") *** devOff() ... DONE > > > message("*** devDone() ... ") *** devDone() ... > > ## Open and close device > idx0 <- devNew() > idx1 <- devDone(idx0) > str(idx1) Named int 1 - attr(*, "names")= chr "null device" > > ## Close same device again (should silently return) > idx2 <- devDone(idx0) > str(idx2) Named int 1 - attr(*, "names")= chr "null device" > > stopifnot(identical(idx2, idx1)) > > ## Close many devices > idx3 <- devDone(1:5) > str(idx3) Named int 1 - attr(*, "names")= chr "null device" > > message("*** devDone() ... DONE") *** devDone() ... DONE > > message("*** devNew() ... DONE") *** devNew() ... DONE > > proc.time() user system elapsed 0.56 0.20 0.75