Dear friends, I will be very happy if anyone tell me the way to change work directory permanently? I mean not use the function setwd() which can only change temporary, when you close the console, it will the old directory. Sys.setenv(R_USER = '') also doesn't work. [[alternative HTML version deleted]]
Which OS and how do you start R? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Huidong TIAN > Sent: Friday, October 30, 2009 5:36 AM > To: r-help at r-project.org > Subject: Re: [R] R-help Digest, Vol 80, Issue 30 > > Dear friends, > > I will be very happy if anyone tell me the way to change work directory > permanently? > I mean not use the function setwd() which can only change temporary, > when > you close the console, it will the old directory. > Sys.setenv(R_USER = '') also doesn't work. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
On 10/30/2009 10:35 PM, Huidong TIAN wrote:> Dear friends, > > I will be very happy if anyone tell me the way to change work directory > permanently? > I mean not use the function setwd() which can only change temporary, when > you close the console, it will the old directory. > Sys.setenv(R_USER = '') also doesn't work. > >Hi Huidong, There are a few ways. One is to define a .First function in the directory where R starts and include the setwd() command in that: .First<-function() { setwd("/home/huidong/R") } If you start up a new R session, create the .First function and then answer "y" to: Save workspace image? [y/n/c]: this function will be run when you start up R. You can add other commands to customize the R session, but remember to do so in a fresh session, then quit saving the workspace image each time you change .First. Jim