From rksh at soc.soton.ac.uk  Mon Nov 29 11:34:19 2004
From: rksh at soc.soton.ac.uk (Robin Hankin)
Date: Mon Nov 29 11:35:19 2004
Subject: [Rd] data() in data/*.R files
Message-ID: <a0620070cbdccc895fa72@[139.166.242.29]>

Hi

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]]


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