[Rd] possible bug: graphics::image seems to ignore getOption("preferRaster")

Dr Gregory Jefferis jefferis at mrc-lmb.cam.ac.uk
Thu Mar 20 01:22:19 CET 2014

the details section of ?image says:

> If useRaster is not specified, raster images are used when the 
> getOption("preferRaster") is true, the grid is regular and either 
> dev.capabilities("raster") is "yes" or it is "non-missing" and there 
> are no missing values.

but in my experience this is never the case and 
getOption("preferRaster") is ignored. As far as I can see, the logic for 
checking this is in image is broken here:

   ras <- dev.capabilities("raster")
   if (identical(ras, "yes"))
     useRaster <- TRUE

because dev.capabilities("raster") returns a list like this (on my 
machine, R.version in footer)
> $rasterImage
> [1] "yes"

You can test this by doing:

   ras=structure(list(rasterImage = "yes"), .Names = "rasterImage")
   identical(ras,'yes') # returns FALSE

so the test would need to be something like:

   ras <- dev.capabilities("raster")[[1]]
   if (identical(ras, "yes"))
     useRaster <- TRUE

I can't find any relevant changes in R news

This discussion


suggests that Simon Urbanek may have added the useRaster option and 
looking at git blame on this mirror repo:


suggests that Brian Ripley's svn commit 56949 was the last to touch 
these lines:


Thanks for any pointers if I am missing something!

Best wishes,

Greg Jefferis.

> R.version
platform       x86_64-apple-darwin10.8.0
arch           x86_64
os             darwin10.8.0
system         x86_64, darwin10.8.0
major          3
minor          0.3
year           2014
month          03
day            06
svn rev        65126
language       R
version.string R version 3.0.3 (2014-03-06)
nickname       Warm Puppy

Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK


More information about the R-devel mailing list