I have some data files with my library which are used for examples and testing
the code. To date I have kept them in a subdirectory I called ../dse/dsedata,
but I am trying to move those to .../dse/data as perscribed for installing
libraries. However, these datasets are not all R object, some are just files
that I source from within a function, and one is accessed by a separate process
that I call from R.
1/ Should the data subdirectory be reserved for R objects?
2/ Could someone explain or point me to were I can find the explanation of how R
objects in this data subdirectory should be constructed? Are these objects
automatically loaded when a library is loaded?
3/ To date I have been able to find my subdirectory by setting a variable
indicating its location in the library file from which code is loaded.
Admittedly this was a kludge, but I could do it because I had my own make which
embedded the location in the file when it was installed. I was not very happy
with this trick, but it seems I completely lose this ability using R INSTALL.
From within R is there a good way to find the location of a library when it is
loaded or after it is loaded?
Paul Gilbert
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I have some data files with my library which are used for examples and
testing the code. To date I have kept them in a subdirectory I called
../dse/dsedata, but I am trying to move those to .../dse/data as
perscribed for installing libraries. However, these datasets are not
all R object, some are just files that I source from within a
function, and one is accessed by a separate process that I call from
R.
Official R speak actually is `package' for what you call `library'.
1/ Should the data subdirectory be reserved for R objects?
No. You can have data of any kind ther. However, currently data() only
works for R objects, i.e., files with R code and names ending in `.R'.
Within soon, this should be extended so that e.g. `.tab' is using for
tables (and we still have to determine how to treat headers ...).
2/ Could someone explain or point me to were I can find the
explanation of how R objects in this data subdirectory should be
constructed? Are these objects automatically loaded when a library is
loaded?
No, they are not loaded automatically. Currently, there is (still) no
way to attach a directory. This will change eventually.
If you build a package for use with R and there is no reason to store
data in a specific format, you might as well try to dump() your object
and put the result of that into the data dir of the pkg (thus you'd have
sourceable R code etc.) If you want to distribute something in some
other format, e.g. `file.of', then `file.R' should contain the R code
for reading the contents of `file.of' into R.
3/ To date I have been able to find my subdirectory by setting a
variable indicating its location in the library file from which code
is loaded. Admittedly this was a kludge, but I could do it because I
had my own make which embedded the location in the file when it was
installed. I was not very happy with this trick, but it seems I
completely lose this ability using R INSTALL. >> From within R is
there a good way to find the location of a library when it is loaded
or after it is loaded?
Not quite. There is a function called system.file() which does
something similar:
R> system.file("R/base")
[1] "/usr/local/lib/R/library/base/R/base"
R> system.file("data/index.doc")
[1] "/usr/local/lib/R/library/base/data/index.doc"
system.file("*/index.doc")
[1] "/usr/local/lib/R/library/base/data/index.doc"
Would it be important to know the location of a package?
-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Official R speak actually is `package' for what you call `library'.
Yes, I forgot, sorry.
Thanks for all the other details.
Would it be important to know the location of a package?
Probably not for the code, but if I put data in .../dse/data then I need to know
where it is in order to load it (and sometimes to pass the location to other
processes to load it). The way I've done this in S is to set a global variable
in .First.lib using the library and section arguments, but I don't think this is
available in R yet.
Paul
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1/ Should the data subdirectory be reserved for R objects?
No. You can have data of any kind ther. However, currently data() only
works for R objects, i.e., files with R code and names ending in `.R'.
What about files ending in .r?
(= result of copying a .R file on a dos formatted floppy disk).
Will they be recognized as R code files?
I have already mentioned this problem a few days ago, but there has not
been any reaction.
Thanks,
Philippe
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._