[R] include a dataset in my package

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue May 22 14:25:51 CEST 2012



On 22.05.2012 06:24, Richard M. Heiberger wrote:
> you do have a dataset x. it is probably inside the test.rda file.
>
> start a fresh R session and library(yourPackage)
>
> then
> ls()
> data(test)

No, you meant

data(x)

Note that the name of the filename is still the original mname it had 
hen creating the rda file, the filename of the rda file is irrelevant 
(and it may contain more than just one object).

Best,
Uwe Ligges



> ls()  ## you will probably have now have x.
>
> Should you need to use load, then use
> load("/full/path/to/test.rda")  ## in quotes
> ls()
>
> The idiom for saving a dataset is
> save(mydataset, file="mydataset.rda")
>
> On Mon, May 21, 2012 at 8:45 PM, di jianing<jianingdi at gmail.com>  wrote:
>
>> Hey R-users,
>>
>> I think I followed the steps but still couldn't figure this out.. I am
>> creating a personal package and I want to include several datasets in
>> the package. I created a subdirectory 'data' in the package, save a
>> dataset 'test.rda' there, built the package, checked it, installed it.
>> Then I loaded the package and tried load(test), data(test),
>> attach(test), none of them gave me the actual data. Another thing,
>> which I am not sure if it is relevant, is that when I was checking the
>> package before installation, I got a warning (not an error) that I
>> have a dataset 'x' without document. I actually don't have any dataset
>> with the name 'x'.
>>
>> Any thoughts?
>>
>> thanks!
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list