[R-sig-teaching] workspace management

Hadley Wickham hadley at rice.edu
Tue Nov 2 23:13:12 CET 2010


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




More information about the R-sig-teaching mailing list