I use the select.list when I have welldefined the paths and the fix function
when not
I start idetifyind the unit, and then the rest of the path:
unit <- select.list(paste(letters,":/",sep=""))
paths <- c("Projects/Data/", "MyPenDrive/Projects/Data")
path <- select.list(paths)
path <- paste(unit,path,sep="")
So I can work with the same program in any computer using my pendrive, or in my
computer using my own path.
If there is not a fixed path:
path <- "c:/new path/"
fix(path)
You can use the select-list function to choose between different platforms,
(Linux, Mac, Windows):
OS <- select.list("Lunix,"Mac","Windows")
if (OS=="Linux") then { # use the select.list function with paths in Linux
format (//users//) }
if (OS=="Windows") then { # use the select.list function with paths in Linux
format (c:/) }
Sorry by my english,
david
El 02/11/2010, a las 23:13, Hadley Wickham escribió:
>> Actually I find a hard-coded path *especially* useful when I'm using more
>> than one computer as it reminds me of what directory I'm suppose to be
>> working in.
>>
>> I write code like
>>
>> wbf = #"C:\\Files\\Consulting\\Cilla\\Wetaboxes 1.7.09.csv"
>> "C:\\Users\\maj\\Documents\\Consulting\\Cilla\\Wetaboxes 1.7.09.csv"
>> longterm = read.csv(wbf,header=TRUE)
>>
>> and move the # around depending on what computer I'm on.
>
> But that's exactly what the idea of a working directory is to avoid.
> Just set all paths relative to the R file, and then set the working
> directory (or use source + chdir = T) and you're golden. Admittedly
> this works best from the command line, where the directory you start R
> from becomes the working directory.
>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
david monterde > 678 374 830 > [email protected]
Lo difícil se hace. Lo imposible se intenta
[[alternative HTML version deleted]]
_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-teaching