[Rd] data() in data/*.R files

From: Robin Hankin <rksh_at_soc.soton.ac.uk>
Date: Mon 29 Nov 2004 - 21:34:19 EST


I'm having difficulty making a package pass R CMD check.

I need to read in a dataset from another package, modify it, and have the modified object available in the first package. help(require) says:

      The source code for a package that requires one or more other
      packages should have a call to 'require', preferably near the
      beginning of the source, and of course before any code that uses
      functions, classes or methods from the other package.

and 200update.txt points out that the data/*.R files must be self sufficient, suggesting "require(pkg, quietly=TRUE, save=FALSE)" if needed. My .R file in the data subdirectory looks like this:

   require(calibrator, quietly=TRUE, save=FALSE)    data(expert.estimates, package="calibrator")    <paraphrase>
  expert.estimates.modified <- some.function(expert.estimates)    </paraphrase>

  But if I do this, R CMD check says

Error in eval(expr, envir, enclos) : couldn't find function "data" Execution halted
ERROR: installing package indices failed   ERROR
Installation failed.

[the package passes R CMD check if I cut-and-paste a dput and assign expert.estimates.modified
directly, and dispense with the data() statement].

How do I load a dataset from another package in a .R file, and use it?

Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
SO14 3ZH
tel +44(0)23-8059-7743
initialDOTsurname@soc.soton.ac.uk (edit in obvious way; spam precaution)
	[[alternative HTML version deleted]]

R-devel@stat.math.ethz.ch mailing list
Received on Mon Nov 29 21:56:53 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:51 EST