[Bioc-devel] importing a function that uses data()

J.Oosting at lumc.nl J.Oosting at lumc.nl
Sat Aug 18 00:33:12 CEST 2012

Hi Martin,

Thanks for looking into this. I had just integrated the chrom.bands data.frame into my package after the demise of the lodplot package. I had seen the envir argument, but was unsure how to use it from within the package.

I will now amend the occurences in the quantsmooth package.

Kind regards,


Van: Martin Morgan [mtmorgan at fhcrc.org]
Verzonden: vrijdag 17 augustus 2012 22:25
Aan: Stephanie M. Gogarten
CC: bioc-devel at r-project.org; Oosting, J. (PATH)
Onderwerp: Re: [Bioc-devel] importing a function that uses data()

On 08/17/2012 10:07 AM, Stephanie M. Gogarten wrote:
> In GWASTools, I import the paintCytobands function from quantsmooth:
> importFrom(quantsmooth, paintCytobands, lengthChromosome)
> The paintCytobands function loads a data set called chrom.bands:
> data(chrom.bands)
> In creating my package vignette, I now get the error:
> Warning in data(chrom.bands) : data set ‘chrom.bands’ not found
> Error: processing vignette ‘DataCleaning.Rnw’ failed with diagnostics:
>   chunk 100
> Error in subset(chrom.bands, chrom.bands$chr %in% chrom) :
>    object ‘chrom.bands’ not found
> I can fix this by including the quantsmooth package in "Depends" rather
> than "Imports," but I am wondering if there is a better way?

Hi Stephanie (and quantsmooth and other package maintainers) --

I looked in to this. I think quantsmooth should say

   data(chrom.bands, package="quantsmooth", envir=environment())

in paintCytobands (and elsewhere).

Although the documentation for ?data is a bit ambiguous, it says that if
the 'package' argument is not specified then the data is looked for in
packages on the search() path. But (a) an Import'ed package is not on
the search path and (b) even if it were, its data set could be masked by
some other package. So providing a 'package' argument seems like a best

The default value for envir is .GlobalEnv, which means that the data is
loaded to the global environment and in the process writes over any
identically named variables that are already defined there. The
environment() value is the environment of the function in which the call
to data() is evaluated, so worst-case is that the author of the original
function clobbers variables in their own function.


> thanks,
> Stephanie
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel

Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

More information about the Bioc-devel mailing list