Skip to contents
library(saferGraph)


Argument kind

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>    agg_png postscript        pdf 
>          2          3          4
close2(kind = "pdf")
grDevices::dev.list() # only remains the postscript devices
>    agg_png postscript 
>          2          3
grDevices::graphics.off()


postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
close2(kind = c("pdf", "postscript"))
> Error: 
> 
> ================
> 
> ERROR IN close2()
> THE kind OBJECT MUST BE SOME OF THESE OPTIONS: windows quartz x11 X11 pdf bmp png tiff
> THE PROBLEMATIC ELEMENTS OF kind ARE: postscript
> 
> ================
grDevices::dev.list()
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
grDevices::graphics.off()


Argument return.text

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>    agg_png postscript        pdf 
>          2          3          4
close2(kind = "pdf", return.text = TRUE)
> [1] "THE REQUIRED KIND OF GRAPHIC DEVICES TO CLOSE ARE pdf\npdf DEVICE NUMBER 4 HAS BEEN CLOSED"
grDevices::dev.list() # only remains the postscript devices
>    agg_png postscript 
>          2          3
grDevices::graphics.off()

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
close2(kind = c("pdf"), return.text = FALSE) ; 
grDevices::dev.list() # only remains the postscript devices
> postscript postscript 
>          3          5
grDevices::graphics.off()


Argument safer_check

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>    agg_png postscript        pdf postscript        pdf 
>          2          3          4          5          6
close2(kind = c("pdf"), safer_check = TRUE)
grDevices::dev.list()
>    agg_png postscript postscript 
>          2          3          5
grDevices::graphics.off()


All the arguments

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>    agg_png postscript        pdf postscript        pdf 
>          2          3          4          5          6
close2(kind = c("pdf"), return.text = TRUE, safer_check = TRUE) ; 
> [1] "THE REQUIRED KIND OF GRAPHIC DEVICES TO CLOSE ARE pdf\npdf DEVICE NUMBER 6 HAS BEEN CLOSED\npdf DEVICE NUMBER 4 HAS BEEN CLOSED"
grDevices::dev.list() # only remains the postscript devices
>    agg_png postscript postscript 
>          2          3          5
grDevices::graphics.off()


postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
grDevices::dev.list() ; 
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
close2(kind = c("pdf"), return.text = FALSE, safer_check = TRUE) ; 
grDevices::dev.list() # only remains the postscript devices
> postscript postscript 
>          3          5
grDevices::graphics.off()


postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
close2(kind = c("pdf", "postscript"), return.text = TRUE, safer_check = TRUE)
> Error: 
> 
> ================
> 
> ERROR IN close2()
> THE kind OBJECT MUST BE SOME OF THESE OPTIONS: windows quartz x11 X11 pdf bmp png tiff
> THE PROBLEMATIC ELEMENTS OF kind ARE: postscript
> 
> ================
grDevices::dev.list() # only remains the postscript devices
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
grDevices::graphics.off()

postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
postscript("file") # open a postscript graphic device
pdf("file") # open a pdf graphic device
close2(kind = c("pdf", "postscript"), return.text = FALSE, safer_check = TRUE)
> Error: 
> 
> ================
> 
> ERROR IN close2()
> THE kind OBJECT MUST BE SOME OF THESE OPTIONS: windows quartz x11 X11 pdf bmp png tiff
> THE PROBLEMATIC ELEMENTS OF kind ARE: postscript
> 
> ================
grDevices::dev.list() # only remains the postscript devices
>        pdf postscript        pdf postscript        pdf 
>          2          3          4          5          6
grDevices::graphics.off()