[R] access data inside package

baptiste Auguié ba208 at exeter.ac.uk
Tue Jan 1 10:20:58 CET 2008


Dear all,

Happy new year!

I posted a very similar question a few days ago, but probably too  
cluttered. Here is a tidy, minimal version:

I want to make a package, with a data.frame d and a function f given  
below. Now, the function f needs to use the data.frame d. I could  
(and that's what I've done temporarily) make a local duplicate of  
this data.frame in the function definition, but it seems silly.

I've tried "attach()", "data()", but both fail when running R CMD  
check with the error

> * checking R code for possible problems ... NOTE
> f: no visible binding for global variable 'd'

Here is the minimal package skeleton:

> d <- data.frame(a=1)
>
> f <- function(x)
> {
> 	data("d")
> 	x+d$a
> }
>
> package.skeleton(list=c("f","d"), name="mypkg")


What would be a sensible way to refer to this data inside the package?

Best regards,

baptiste

_____________________________

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto




More information about the R-help mailing list