Re: [Rd] datalist and data objects in R Package building

From: andrew stewart <andrew.c.stewart_at_gmail.com>
Date: Mon, 28 Mar 2011 11:49:49 -0400

Thank you for your response.

Yes, using a call to data() after 1) building and 2) installing my own package is exactly what I'm trying to accomplish. I am building a package.  I would like to load the data objects that are part of the custom package that I have created and installed on my machine. Apologies if I wasn't clear about that part.

2011/3/28 Uwe Ligges <ligges_at_statistik.tu-dortmund.de>

>
>
> On 24.03.2011 16:51, andrew stewart wrote:
>
>> Hello all,
>>
>> I have,say 4 R objects... bar1, bar2, bar3, bar4.. that I'd like to
>> include
>> in an R package "foobar".
>>
>> The desired functionality would be:
>>
>> library(foobar)
>>> data(foo)
>>> ls()
>>>
>> [1] "bar1" "bar2" "bar3" "bar4"
>>
>> I've tried the following two approaches:
>>
>> 1) I created the file 'datalist' under pre-build directory 'foobar/data/'
>> with the following contents:
>> foo: bar1 bar2 bar3 bar4
>>
>> After package build and install, "data(foo)" reports that data set 'foo'
>> not
>> found (bar1, bar2, etc are all available individually, and are listed
>> under
>> data() as "bar1 (foo)".
>>
>
>
> If you want just one object "foo", then prpare a list
>
> foo <- list(bar1,...)
>
> that contains the 4 objects bar1, ... .
> You can load that objects and access the list components afterwards.
>
> I think you misunderstood the data concept: You can save objects and load
> them if the package is installed. That's it.
>
> Best,
> Uwe Ligges
>
>
>
> 2) I created an image via save.image resulting in foo.rda (containing
>> bar1,
>> bar2, etc).
>>
>> data(foo) now loads bar1 - bar4, but 'foo' doesn't appear in the list of
>> available datasets displayed when trying to tab complete within data().
>>
>>
>> So my question is, what's the correct approach for what I'm trying to do
>> here? Any advice welcome and appreciated.
>>
>> Thanks,
>> Andrew
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 28 Mar 2011 - 16:15:08 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 Mon 28 Mar 2011 - 17:00:38 GMT.

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

list of date sections of archive