Re: [R] access data inside package

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Wed, 02 Jan 2008 13:31:14 +0100

baptiste Auguié wrote:
> Thanks, that works for me!
>
> On 1 Jan 2008, at 15:47, Uwe Ligges wrote:

>>
>> baptiste Auguié wrote:
>>> 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'
>>
>>
>> This is just a note, you can either ignore it or use a dirty trick to 
>> circumvent Luke's checks by
>>    d <- get("d")
>> Perhaps it is better to get from the correct environment by specifying 
>> it.
>>
>> Uwe

>
> I know you're right, but I have no idea which one to pick: the
> environment help page confuses me a lot.

d <- get("d", pos=globalenv())

Uwe

> Thanks again,
>
> baptiste
>

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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jan 2008 - 12:35:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Jan 2008 - 21:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive