From ligges at statistik.uni-dortmund.de  Mon Nov 29 12:34:30 2004
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Mon Nov 29 12:52:38 2004
Subject: [Rd] data() in data/*.R files
In-Reply-To: <a0620070cbdccc895fa72@[139.166.242.29]>
References: <a0620070cbdccc895fa72@[139.166.242.29]>
Message-ID: <41AB0946.3090400@statistik.uni-dortmund.de>

Robin Hankin wrote:

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

You need to require(utils) (the package data() is in),
as well as a corresponsing entry in the DESCRIPTION file.
Also, for Windows, you may need to add the line
ZipData: no
to your DESCRIPTION file, but I am not sure about the latter (and 
haven't tested yet).

Uwe




> 
>


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