[R] R package-building
Tim Hoar
thoar at cgd.ucar.edu
Thu Jan 10 23:02:47 CET 2002
OK, got it.
I REALLY, REALLY don't have a datafile that is in a data()'able format,
yet my examples need to be able to read in a file (that has a dynamic
absolute path). I did not understand the PATH differences between load()
and data() and that .package.path would work for a package that was
in the "check" state.
My real example file is RadioSonde/data/ExampleSonde.txt
If I change my example to:
filename <- paste(.path.package("RadioSonde"),"data","ExampleSonde.txt",sep="/")
sample.sonde <- getsonde(filename)
R CMD [check,build,INSTALL] all work and pretty much gets the point
across that you supply a stinking filename. You have to sort of TRUST that
it works during "check", because running it from the command line a`priori
will not work because there is no RadioSonde package, hence no .path.package
By-the-way the nuances between load() and data() are not documented terribly
well, in my opinion. If you care, see below the "-=-=-=-=-".
With RadioSonde/data/sample.sonde.RData
If my example is:
load("sample.sonde") "R CMD check" bombs
data("sample.sonde") "R CMD check" works OK, but my datafiles cannot
be used in this manner.
Thanks to all who replied -- Tim
-=-=-=-=-=-=-=-=-=-=-
I hate it when people give negative comments without specifying something
better. So -- in order to avoid hating myself:
In an effort to give the people who write the documentation a little
feedback, the distinction between "load()" and "data()" is not clear.
Since they both read stuff created by save(), and ?save only mentions
using load() I didn't think too much of using load() instead of data().
Furthermore, ?data doesn't actually give hints as to how to _make_ an
acceptable input.
For concrete suggestions, here goes:
?save does not mention data(), only load(), dput(), dump()
and implicity states the companion is "load".
The Writing R Extensions manual says to use save(...ascii=T), which I did,
but only mentions using data(), not load() (and for good reason, apparently).
It would be nice if the manual made clear why load() might not work.
?data does not actually tell you how to create a file you can ingest
with data(), and does not mention save() in the "seealso" but says
" 1. files ending `.RData' or `.rda' are `load()'ed. " so people
have to look up load() to find save().
## Tim Hoar, Associate Scientist email: thoar at ucar.edu ##
## Geophysical Statistics Project phone: 303-497-1708 ##
## National Center for Atmospheric Research FAX : 303-497-1333 ##
## Boulder, CO 80307 http://www.cgd.ucar.edu/~thoar ##
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list