[R] create dataset permanently in package (i.e. default or our own package)

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Jul 27 17:59:26 CEST 2009


Mr. Einstein,

On Jul 27, 2009, at 7:27 AM, Albert EINstEIN wrote:

> Hi,
> actually while opening R console and R commander we see some  
> packages like
> car and datasets. in this packages we have default datasets are  
> available.
> example: women and prestige like that. now i created a sales dataset
> importing from excel, xml or text file. now i want to store that  
> dataset
> permanently  in any one of the package like i mentioned above (car or
> datasets). now i closed my R session. after some time i opened R  
> console and
> R commander. Now I will not create again sales dataset.While  
> clicking any
> one of package that sales dataset should be found.
> if possible please give me the code it will be very helpful for us.

I'm not sure if this is exactly what you're asking, but this is the  
question I'm going to answer:

How can I include/bundle a dataset with a package that I am developing?

Answer:

Simply save your dataset into an *.rda/*.RData file and place it in  
the data directory of the package you're developing.

So, for example, let's say you've done so and the name of your file is  
"TheoryOfRelativity.rda".Once the package is installed (and  
loaded(?)), you can load the datafile it by calling:

data(TheoryOfRelativity)

====

I'm not sure that saving your own data file into *some random*  
package's data directory is a good idea, or what you're asking, but  
you can do that, too. Just specify the package you need to load it from.

For example, if I saved 'TheoryOfRelativity.rda' in the 'nnet'  
package's data directory (for some weird reason). You can load it like  
so:

load(TheoryOfRelativity, package='nnet')

HTH,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list