Dear R Can you tell me how to change the working directory of R It's just that I have some text files that I wish to save separately from the R filing structure eg. into C:/my documents and need to change the working directory of R so that it reads these files . This means if I ever upgrade the current version of R nothing will be effected. brett Brett Stansfield Environmental Scientist - Water Quality Hawke's Bay Regional Council 102 Vautier Street Private Bag 6006 Napier Phone (06) 835-9200 extn 9334 Fax (06) 835-3601
help.search("working directory") The R folks have worked very hard to provide good documentation. Please make use of the Help system and other resources before posting, as the Posting Guide asks (below). -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Brett > Stansfield > Sent: Monday, February 28, 2005 3:34 PM > To: R help (E-mail) > Subject: [R] (no subject) > > Dear R > Can you tell me how to change the working directory of R > > It's just that I have some text files that I wish to save > separately from > the R filing structure eg. into C:/my documents and need to change the > working directory of R so that it reads these files . This > means if I ever > upgrade the current version of R nothing will be effected. > > brett > > Brett Stansfield > Environmental Scientist - Water Quality > Hawke's Bay Regional Council > 102 Vautier Street > Private Bag 6006 > Napier > Phone (06) 835-9200 extn 9334 > Fax (06) 835-3601 > > ______________________________________________ > 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 >
'help.search("working directory")' identifies "getwd", the help file for which describes "setwd". Similarly, "www.r-project.org" -> search -> "R site search" for "working directory" produced 564 hits. I checked the first 4, and they all mentioned either getwd or setwd. hope this helps. spencer graves Brett Stansfield wrote:>Dear R >Can you tell me how to change the working directory of R > >It's just that I have some text files that I wish to save separately from >the R filing structure eg. into C:/my documents and need to change the >working directory of R so that it reads these files . This means if I ever >upgrade the current version of R nothing will be effected. > >brett > >Brett Stansfield >Environmental Scientist - Water Quality >Hawke's Bay Regional Council >102 Vautier Street >Private Bag 6006 >Napier >Phone (06) 835-9200 extn 9334 >Fax (06) 835-3601 > >______________________________________________ >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 > >
Reading the posting guide http://www.R-project.org/posting-guide.html will tell you to specify an informative subject line in your postings. You can change working directory by using setwd(), see help("setwd"). For example setwd("c:\My Documents") might work. I am not sure if you need to truncate the path names to 8 characters anymore. But if you want to read files in other directory, you can do so without changing your current working directory. As long as you can supply the absolute or full path, you should be fine. For example read.delim(file="c:\My Documents\project1\datafile.txt") would read that file into R regardless of current directory. If you use absolute paths and if you saved the commands onto a script file, then you can re-execute these command under whatever version of R. I would recommend this approach since you will have a rather static working directory. Regards, Adai On Tue, 2005-03-01 at 12:33 +1300, Brett Stansfield wrote:> Dear R > Can you tell me how to change the working directory of R > > It's just that I have some text files that I wish to save separately from > the R filing structure eg. into C:/my documents and need to change the > working directory of R so that it reads these files . This means if I ever > upgrade the current version of R nothing will be effected. > > brett > > Brett Stansfield > Environmental Scientist - Water Quality > Hawke's Bay Regional Council > 102 Vautier Street > Private Bag 6006 > Napier > Phone (06) 835-9200 extn 9334 > Fax (06) 835-3601 > > ______________________________________________ > 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 >