[Rd] appropriate work-around for problems with a specific plot device (Rstudio)?

Skye Bender-deMoll skyebend at skyeome.net
Fri Oct 25 02:13:05 CEST 2013

Dear r-devel-opers,

I'm working on a package that does some plot-intensive work using the 
animation library.  It turns out that this performs very badly in the 
RStudio plot device, which is the preferred IDE for our team.  Our 
kludgy solution is to detect if the Rstudio device is running, and if 
so, open another plot device to do the rendering and close it when done:

   if (!is.function(options()$device)){
     if (names(dev.cur())=="RStudioGD"){
       message("RStudio's graphics device is not well supported by ndtv, 
attempting to open another type of plot window")
       # try to open a new platform-appropriate plot window
       if (.Platform$OS.type=='windows'){
       } else if(length(grep(R.version$platform,pattern='apple'))>0)  # 
is it mac?
       } else {  # must be unix

[render a whole bunch of plot frames]

# turn off external device if using one
   if (externalDevice){

Although this works well for us in practice, when testing against R 
devel, we get the following NOTE:

* checking R code for possible problems ... NOTE
Found an obsolete/platform-specific call in the following function:
Found the platform-specific devices:
   ‘quartz’ ‘windows’ ‘x11’
dev.new() is the preferred way to open a new device, in the unlikely
event one is needed.

Is there a better way to resolve this situation?  We can't use dev.new() 
to open the plot device, because RStudio has set the value of 
getOption("device") to "RStudioGD".  Can anyone recommend an alternative 
method of generating a platform-appropriate device to open that won't 
generate R CMD check issues?

Thanks for your help,

More information about the R-devel mailing list