[R] set up directory for R when I start R

Jim Lemon jim at bitwrit.com.au
Sun Dec 10 12:45:11 CET 2006


Aimin Yan wrote:
> I want to set default directory for R when I start R.
> How to do this?
> 
Hi Aimin,
There is a discussion of how to set up different start up commands, 
usually for attaching to icons, in "Kickstarting R":

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

You can also write an R file that can branch to a number of different 
directories on start up. Basically a bunch of statements like:

cat("(C)at studies\n")
cat("(D)og studies\n")
...
answer<-readline("")
if(toupper(strsplit(answer,"")[1]) == "C") setwd("/home/jim/cats")
if(toupper(strsplit(answer,"")[1]) == "D") setwd("/home/jim/dogs")
...


Jim




More information about the R-help mailing list