[R] Creating datasets

Jim Lemon bitwrit at ozemail.com.au
Sat Jun 4 00:46:37 CEST 2005


Hi folks,

Having lost count of the times I have read the relevant section in 
R-exts.html (and by the way, where has that useful file gone? I had to 
look at it on CRAN.), searched for "creating datasets" (this is the 
first time that Jon Baron's excellent search site has let me down) and 
read the idiot's guide for creating packages, I am willing to admit that 
I have failed the test.

First:
Linux (Fedora Core 2)
R-2.1.0

I am attempting to integrate three functions that have been kindly 
donated to the plotrix package by Sander Oom dealing with plotting soil 
texture. Everything works okay, but I want to add a dataset to the 
package. R-exts says that three types of data files are okay:

R code, rectangular tables (e.g. CSV) or files created by save (.rda)

I note that all the "real" packages (oops, bundles) like MASS have three 
files in their data directory that look like an index of the datasets, 
the datasets themselves and something I haven't worked out yet. I 
haven't found a description of how to do that trick.

Thus I created the dataset by reading a CSV data file into a data frame

oksoil<-read.table("oksoil.csv",sep=",")

That data frame works fine in all the functions. Then I saved it:

save(oksoil,file="/home/jim/R/plotrix/data/oksoil.rda")

But when I check the package, the examples don't work:

R CMD check /home/jim/R/plotrix
...
 >  data(oksoil)
Warning in data(oksoil) : data set 'oksoil' not found
 >  # first just show the soil triangle
 >  soil.texture()
 >  # now plot the observations
 >  show.soil.texture(oksoil)
Error in show.soil.texture(oksoil) : Object "oksoil" not found
Execution halted

I promise to try writing an "Idiot's Guide to Creating Datasets" if 
someone can provide a method.

Jim




More information about the R-help mailing list