[R] system-independent path for source()

Thomas Lumley tlumley at u.washington.edu
Wed Feb 20 22:32:50 CET 2002


On Wed, 20 Feb 2002, Prof Brian Ripley wrote:

> All contributions welcome, Thomas!

This seems to be a bit better than the current version, and I'll add it

 file.path<-function (..., fsep = .Platform$file.sep,absolute=FALSE) {
    rval<-paste(..., sep = fsep)
    if (xor(absolute,.Platform$OS.type=="mac"))
        rval<-paste("",rval,sep=fsep)
    rval
 }

so now I can do
  file.path("Macintosh HD","Users","thomas",absolute=TRUE)
or
  file.path("Users","thomas")
for a relative path.

The real question is what to do about disks. In Windows you need the disk
name to find files on other disks but on the Mac you seem to need the
disk name even to find the root of the current disk.

It could be taken from getwd() but that seems to make file.path() a lot
more complicated and less portable.

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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