I have a function that calls multiple windows (new graphics device window). To make this happen I use windows(). This works but as this is for a package how do I make it platform neutral so each plot gets plotted in a new window while leaving the old window?
What I currently have:
WORD.C <- function(WORDS){
require(wordcloud)
L2 <- lapply(WORDS, function(x) as.data.frame(table(x), stringsAsFactors = FALSE))
FUN <- function(X){
windows() #how to make this platform neutral
wordcloud(X[, 1], X[, 2], min.freq=1)
}
lapply(L2, FUN)
}
WORD.C(list.xy)
Will dev.new() cover your needs? It opens a graphics window of the default type set up in your console sessions.
The Mac will generally open up an X11 window, so this might be a minimal solution:
if( .Platform$OS.type =="unix" ) { X11() } else { windows() }
If you want to branch on the GUI type then you could use:
if( .Platform$GUI %in% ("X11", "Tk") ) { X11() } else {
if ( .Platform$GUI == "AQUA" ){ quartz()} else {
windows() } }
# For more details
?.Platform
?Devices
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With