I would like to use the same source files with UNIX and MacOS Carbon versions of R. Some of these source files access other source files through the source function, but UNIX separates directories with "/" and MacOS separates them with ":" and the beginning of the path is also different on each system. Is there a way to write the source files so that they can use source() with system-independent paths? Or would it be easier for me to convert the source files to packages and use library()? http://www.mcg.edu/research/biostat/bickel.html David R. Bickel, PhD Assistant Professor Medical College of Georgia Office of Biostatistics and Bioinformatics 1120 Fifteenth St., AE-3037 Augusta, GA 30912-4900 Tel.: 706-721-4697; Fax: 706-721-6294 E-mail: dbickel at mail.mcg.edu or bickel at prueba.info -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 808 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020220/c1750e32/attachment.bin
system-independent path for source()
7 messages · David R. Bickel, Brian Ripley, Thomas Lumley
On Wed, 20 Feb 2002, David R. Bickel wrote:
I would like to use the same source files with UNIX and MacOS Carbon versions of R. Some of these source files access other source files through the source function, but UNIX separates directories with "/" and MacOS separates them with ":" and the beginning of the path is also different on each system. Is there a way to write the source files so that they can use source() with system-independent paths?
file.path.
Or would it be easier for me to convert the source files to packages and use library()? http://www.mcg.edu/research/biostat/bickel.html David R. Bickel, PhD Assistant Professor Medical College of Georgia Office of Biostatistics and Bioinformatics 1120 Fifteenth St., AE-3037 Augusta, GA 30912-4900 Tel.: 706-721-4697; Fax: 706-721-6294 E-mail: dbickel at mail.mcg.edu or bickel at prueba.info
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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thanks for telling me about file.path. That solves the problem of the different separators, but UNIX begins the home path with "/" and MacOS begins the home path with the name of the hard disk.
On Wednesday, February 20, 2002, at 03:03 ?, Prof Brian D Ripley wrote:
file.path
http://www.mcg.edu/research/biostat/bickel.html David R. Bickel, PhD Assistant Professor Medical College of Georgia Office of Biostatistics and Bioinformatics 1120 Fifteenth St., AE-3037 Augusta, GA 30912-4900 Tel.: 706-721-4697; Fax: 706-721-6294 E-mail: dbickel at mail.mcg.edu or bickel at prueba.info -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 20 Feb 2002, David R. Bickel wrote:
Thanks for telling me about file.path. That solves the problem of the different separators, but UNIX begins the home path with "/" and MacOS begins the home path with the name of the hard disk.
The opposite problem also occurs when one wants a relative path
":some:long:path"
is the Mac equivalent of
"some/long/path"
Perhaps file.path() should have an absolute/relative path option?
-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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
All contributions welcome, Thomas!
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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 On Wed, 20 Feb 2002, Thomas Lumley wrote: > On Wed, 20 Feb 2002, David R. Bickel wrote: > > > Thanks for telling me about file.path. That solves the problem of the > > different separators, but UNIX begins the home path with "/" and MacOS > > begins the home path with the name of the hard disk. > > > > The opposite problem also occurs when one wants a relative path > ":some:long:path" > is the Mac equivalent of > "some/long/path" > > Perhaps file.path() should have an absolute/relative path option? > > -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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
That looks good, except the hard disk name should be kept separate from
the user-specified path. Otherwise, a call from MacOS that uses an
absolute path will not work on UNIX.
I suggest modifying your file.path interface:
file.path<-function (..., fsep = .Platform$file.sep,absolute=FALSE,
hard.disk.name = "C") {}
If .Platform$OS.type=="mac" and absolute, then hard.disk.name would be
added to the beginning of the path.
This way, file.path("Users","thomas",absolute=TRUE, hard.disk.name =
"Macintosh HD") would work for both MacOS and UNIX. I think this
interface could also be made to work with Windows.
On Wednesday, February 20, 2002, at 04:32 ?, Thomas Lumley wrote:
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
http://www.mcg.edu/research/biostat/bickel.html David R. Bickel, PhD Assistant Professor Medical College of Georgia Office of Biostatistics and Bioinformatics 1120 Fifteenth St., AE-3037 Augusta, GA 30912-4900 Tel.: 706-721-4697; Fax: 706-721-6294 E-mail: dbickel at mail.mcg.edu or bickel at prueba.info -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._