Re: [R] setting new working directories

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Fri 05 Jan 2007 - 08:02:20 GMT

Bill Shipley wrote:
> Hello, and Happy New Year. My default working directory is getting very
> cluttered. I know that I should be using a different working directory for
> each project (I work in Windows), but do not know how to go about creating
> different ones and moving back and forth between them. I have read Venables
> & Ripley (Modern Applied Statistics with S-PLUS, 1994) but this seems out of
> date with respect to this topic and have searched through the documentation
> but cannot find a clear explanation for doing this. Can someone point me to
> the proper documentation for creating and using different working
> directories from within Windows (please, no comments about switching to
> UNIX...).
> Thanks.
>
I'm not sure to which New Year you refer, but thanks and the same to you.

I think you may want to automatically start up R in a directory for each project. There is a discussion of that in Kickstarting R at:

http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_start.html

Basically, you can create icons on the desktop that will start R in a number of directories. In Windows, don't worry about adding the line to your "R" startup file, just set the "Start Program in" to the desired directory in the Properties dialog of the shortcut.

You can also set up an R file that gives you an interactive choice when the program starts. Create a file like this:

cat("R programming\n")
cat("Animals\n")
cat("Vegetables\n")
cat("Minerals\n")
cat("Type in the first letter of the project -")
answer<-toupper(strsplit(readline(""))[1]) if(answer == "R") setwd("c:/jim/R/programs") if(answer == "A") setwd("c:/jim/things/animals") ...

and say you name it c:\jim\R\SelectProject.R (notice that Windows uses backslashes but you use slashes in R)

put the following line in your .First function:

source("c:/jim/R/SelectProject.R")

and you should be able to select your project and directory on startup.

Jim



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Jan 06 10:44:14 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 06 Jan 2007 - 00:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.