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. Bill Shipley
The basic command for this is setwd() (for "set working directory") You can save your workspace after you use the setwd command, and this will create a .RData file in that directory. In windows you can click on the .RData directory to open R using that particular working directory. You can always check on the current working directory using getwd(). Another useful command in this context is save.image (see ?save.image for details) Abhijit 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. > > Bill Shipley > > ______________________________________________ > 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. >
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.RSiteSearch("working directory") is very helpful. In particular, look at the help pages for getwd() and setwd().> Bill Shipley > > ______________________________________________ > 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.-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
See ?getwd and ?setwd to set the working directory See ?load and ?save to read the workspace. Cheers, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx op inbo.be www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -----Oorspronkelijk bericht----- Van: r-help-bounces op stat.math.ethz.ch [mailto:r-help-bounces op stat.math.ethz.ch] Namens Bill Shipley Verzonden: donderdag 4 januari 2007 15:42 Aan: R help list Onderwerp: [R] setting new working directories 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. Bill Shipley ______________________________________________ R-help op 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.
use setwd() and getwd(). see ?setwd or on the shortcut properties tab, set the target directory to your working dir and have as many shortcuts as working directories. working with R commands does it for me. all the best. A. ----- Original Message ---- From: Bill Shipley <bill.shipley at usherbrooke.ca> To: R help list <r-help at stat.math.ethz.ch> Sent: Thursday, January 4, 2007 9:41:35 AM Subject: [R] setting new working directories 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. Bill Shipley ______________________________________________ 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.
An additional note for Windows. The directory name needs to be written as "C:/Project/Working directory" or "C:\\Project\\Working directory" as opposed to the usual way of referencing directories in Windows. AA wrote:> use setwd() and getwd(). see ?setwd > or on the shortcut properties tab, set the target directory to your working dir and have > as many shortcuts as working directories. > working with R commands does it for me. > all the best. > A. > > ----- Original Message ---- > From: Bill Shipley <bill.shipley at usherbrooke.ca> > To: R help list <r-help at stat.math.ethz.ch> > Sent: Thursday, January 4, 2007 9:41:35 AM > Subject: [R] setting new working directories > > 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. > > Bill Shipley > > ______________________________________________ > 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. > > ______________________________________________ > 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. >
Bill, I like to use Windows Explorer to find folders and then launch R with the selected folder as the working directory. I put some notes online about this: http://research.stowers-institute.org/efg/R/TechNote/WindowsExplorerWorkingDirectory/index.htm efg "Bill Shipley" <bill.shipley at usherbrooke.ca> wrote in message news:001001c7300e$7016b440$bb1ad284 at BIO041...> 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.
On 1/4/2007 9:41 AM, 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...).I don't think R has facilities for creating directories: you would do that in the OS, e.g. in Windows Explorer, right click and ask for "New | Folder". In Windows the easiest way to set a directory as the current working directory is setwd(choose.dir()) In the choose.dir dialog you can type the directory name in standard Windows format (don't worry about escaping \), or you can use the directory browser to choose it. By the way, if you do decide to switch to Unix, you'll have to do without choose.dir() (unless it's in a contributed package somewhere). Duncan Murdoch
If you are working on Windows XP then downlaod the batchfiles distribution whose home page is at: http://code.google.com/p/batchfiles/ This will provide a bunch of batch files that are useful in connection with using R. At the Windows console this command shows you your path path so place Rgui.bat from the batchfiles distribution in any of the folders listed in the path or in the folder you want to be your working directory. Then issue this command at the Windows console: Rgui.bat That will start up R with the working directory set to the current directory. It also automatically finds which version of R you are using from the registry so you don't have to do anything each time you install a new version of R (unlike other methods). On 1/4/07, Bill Shipley <bill.shipley at usherbrooke.ca> 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. > > Bill Shipley > > ______________________________________________ > 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. >
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