I want to set default directory for R when I start R. How to do this? Thanks, Aimin
Aimin Yan <aiminy <at> iastate.edu> writes:> > I want to set default directory for R when I start R. > How to do this? >?setwd In Windows, I prefer the method described in http://tolstoy.newcastle.edu.au/R/help/00b/2454.html Dieter
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
"Dieter Menne" <dieter.menne at menne-biomed.de> wrote in message news:loom.20061210T115836-859 at post.gmane.org...> Aimin Yan <aiminy <at> iastate.edu> writes: > >> >> I want to set default directory for R when I start R. >> How to do this? >> > ?setwd > > In Windows, I prefer the method described in > > http://tolstoy.newcastle.edu.au/R/help/00b/2454.htmlI learned a similar trick by using Regedit to set the registry keys directly. (Years ago someone showed me this trick to start a DOS session). Apparently, either "\Directory\shell" or "\Folder\shell" do the same thing. Do you know if there is a difference? I checked and your suggestion can be modified to even specify a http_proxy, if needed: For example, this works for me under Windows XP, including the proxy server, from any directory chosen using Windows Explorer: ------------ Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\R\command] @="C:\\Program Files\\R\\R-2.4.0\\bin\\Rgui.exe http_proxy=http://proxy01:8080 http_proxy_user=ask" ----------- The above was the exported registry key from what I set manually using RegEdit. I used simply "R" instead of "Run R", like you suggested. efg Earl F. Glynn Bioinformatics Stowers Institute for Medical Research
On 12/11/2006 2:21 PM, Earl F. Glynn wrote:> "Dieter Menne" <dieter.menne at menne-biomed.de> wrote in message > news:loom.20061210T115836-859 at post.gmane.org... >> Aimin Yan <aiminy <at> iastate.edu> writes: >> >>> >>> I want to set default directory for R when I start R. >>> How to do this? >>> >> ?setwd >> >> In Windows, I prefer the method described in >> >> http://tolstoy.newcastle.edu.au/R/help/00b/2454.html > > I learned a similar trick by using Regedit to set the registry keys > directly. (Years ago someone showed me this trick to start a DOS session). > Apparently, either "\Directory\shell" or "\Folder\shell" do the same thing. > Do you know if there is a difference?Folders are shell objects, directories are file system objects. Normally the file system is mapped to folders, but there are other folders too, e.g. the network neighbourhood, printers, etc. Duncan Murdoch> > I checked and your suggestion can be modified to even specify a http_proxy, > if needed: > > For example, this works for me under Windows XP, including the proxy server, > from any directory chosen using Windows Explorer: > > ------------ > Windows Registry Editor Version 5.00 > > [HKEY_CLASSES_ROOT\Folder\shell\R\command] > @="C:\\Program Files\\R\\R-2.4.0\\bin\\Rgui.exe > http_proxy=http://proxy01:8080 http_proxy_user=ask" > ----------- > > The above was the exported registry key from what I set manually using > RegEdit. I used simply "R" instead of "Run R", like you suggested. > > > efg > > Earl F. Glynn > Bioinformatics > Stowers Institute for Medical Research > > ______________________________________________ > R-help at 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.
"Duncan Murdoch" <murdoch at stats.uwo.ca> wrote in message news:457DC8CA.9040604 at stats.uwo.ca...> On 12/11/2006 2:21 PM, Earl F. Glynn wrote: >> "Dieter Menne" <dieter.menne at menne-biomed.de> wrote in message >> news:loom.20061210T115836-859 at post.gmane.org... >>> Aimin Yan <aiminy <at> iastate.edu> writes: >>>> >>>> I want to set default directory for R when I start R. >>>> How to do this? >>> >>> In Windows, I prefer the method described in >>> >>> http://tolstoy.newcastle.edu.au/R/help/00b/2454.htmlIf R version-specific registry keys are used, one can even select from multiple versions of R by right clicking on a directory from Windows Explorer: To add key for R 2.4.0: R2.4.0.reg (delete the proxy part if not needed) ----- Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0] [HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0\command] @="C:\\Program Files\\R\\R-2.4.0\\bin\\Rgui.exe http_proxy=http://proxy01:8080 http_proxy_user=ask" ----- To delete this key: R2.4.0-Delete.reg ----- Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Folder\shell\R 2.4.0] ----- These files can be edited with Windows Notepad and modified for other versions. efg Earl F. Glynn Bioinformatics Stowers Institute for Medical Research