[Rd] data() statement in functions

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 2 10:43:11 CEST 2006


On Wed, 2 Aug 2006, Robin Hankin wrote:

> Hi
> 
> I am writing a package in which a function needs a dataset (of  
> precomputed Stirling
> numbers) to work.   The .rda file resides in the data/ directory.
> 
> Toy example follows:
> 
> 
> f <- function(x){
>    data(logS1)
>    . . . do stuff . . .
>    return(answer)
> }
> 
> 
> Is this a good way to do this?
> What is best practice in such situations?

This is exactly what the sysdata.rda facility is provided for: see 
`Writing R Extensions'.  (It works best for packages with namespaces, as 
then its content is by default not exported.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list