Dear R List, I have created a package (under Windows 2.0.1) with 300+ data sets and <20 or so functions I use in teaching. However, to access the data, one needs to type data(foo) once the package has been installed and loaded. With other packages namely MASS, after the package is installed and loaded with library(MASS), it is possible to refer to a data set say Animals by simply typing Animals at the command prompt. I would like to have similar functionality in my package. Would someone provide some hints as to what I need to do (read about xxx...or provide a line of code) so that the data in the package can be accessed once it is loaded without typing data(foo) all the time. Currently, when I type the name of a function it shows the code for the function. I would like it to also show the data when I type the name of any of the data sets. Thanks for the pointers in advance. Alan- Alan T. Arnholt Associate Professor Dept. of Mathematical Sciences Appalachian State University
Prof Brian Ripley
2005-Apr-17 14:24 UTC
[R] Creating packages with windows (accessing data)
Look at `Writing R Extensions' and the description of the DESCRIPTION file, specifically `LazyData'. That is the manual about packages .... On Sun, 17 Apr 2005, Alan Arnholt wrote:> I have created a package (under Windows 2.0.1) with 300+ data sets and <20 > or so functions I use in teaching. However, to access the data, one needs > to type data(foo) once the package has been installed and loaded. With > other packages namely MASS, after the package is installed and loaded with > library(MASS), it is possible to refer to a data set say Animals by simply > typing Animals at the command prompt. I would like to have similar > functionality in my package. Would someone provide some hints as to what > I need to do (read about xxx...or provide a line of code) so that the data > in the package can be accessed once it is loaded without typing data(foo) > all the time. Currently, when I type the name of a function it shows the > code for the function. I would like it to also show the data when I type > the name of any of the data sets. Thanks for the pointers in advance.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595