[R-pkg-devel] how to make "r-release-osx-x86_64-mavericks" machine support rgl 3D plots

Duncan Murdoch murdoch.duncan at gmail.com
Sun Aug 16 18:21:26 CEST 2015

On 16/08/2015 8:47 AM, Dr Gregory Jefferis wrote:
> Dear Duncan,
> On 12 Aug 2015, at 14:07, Duncan Murdoch wrote:
>> A while ago I added support in rgl to run on headless machines.  Set 
>> the
>> environment variable RGL_USE_NULL=TRUE before loading rgl, and should
>> never try to call X11 (or whatever graphics system you're using).
>> (It's also possible to use options(rgl.useNULL = TRUE) within R.  
>> That's
>> no help to you, but is useful when embedding rgl plots in knitr 
>> documents.)
> Could I just check if this approach can be used to suppress example code 
> including rgl calls when it is running on CRAN as part of R CMD check? I 
> have a package that does not build on r-release-osx-x86_64-mavericks 
> because there appears to be a problem with rgl and the examples fail:
> https://www.r-project.org/nosvn/R.check/r-release-osx-x86_64-mavericks/nat-00check.html
> Of course I could put all the examples inside dontrun blocks, but I do 
> prefer to have them run.

It was designed so that CRAN didn't need to see all the pretty pictures
when running tests.  If they set the environment variable, your tests
might pass.

It is harder for you to implement this yourself, because CRAN frowns on
tests that try to detect whether they're running under CRAN or not.

You could put in "if (interactive())" checks around your displays.  If
you want to check whether the rgl calls are okay, you could do something
like this:

options(rgl.useNULL = TRUE)

# do some rgl plotting, which won't display, but will be tested

# now to display it to users,
if (interactive())

but this displays in a browser, not in an R window.

Duncan Murdoch

More information about the R-package-devel mailing list