Skip to content

[Bioc-devel] using data() inside a package function

2 messages · Stephanie M. Gogarten, Martin Morgan

#
I stored the results of a calculation in the data directory of my 
package, so it can be loaded when needed by a function.

data/relationsMeanVar.RData

I then refer to this in the function as
data(relationsMeanVar)
FS <- relationsMeanVar$FullSibs

This generates a NOTE in R CMD check:
* checking R code for possible problems ... NOTE
ibdPlot: no visible binding for global variable ?relationsMeanVar?

Is there a better way to do this?

thanks,
Stephanie Gogarten
#
On 08/30/2011 10:17 AM, Stephanie M. Gogarten wrote:
Hi Stephanie --

a little speculative on my part but data() as invoked above loads the 
data into the global environment, which would be a bad thing (e.g. 
clobbering variables of the same name the user might have created, but 
in generally having a side-effect). So maybe

   env = new.env(parent=emptyenv())
   data(relationsMeanVar, envir=env)
   FS = env[["relationsMeanVar"]]$FullSibs

I'm not sure whether this calms R CMD check or not, but is probably 
better regardless.

Martin