Paul Baer
2005-Oct-14 16:55 UTC
[R] Setting working directory interactively within a function
Is there anyway to have a function prompt the user for a working directory, equivalent to file.choose()? --Paul
Berton Gunter
2005-Oct-14 17:08 UTC
[R] Setting working directory interactively within a function
?setwd e.g. setwd(file.choose()) BTW, you could have found this on your own via help.search('working directory') . Base R has quite good docs -- you should try them first. -- 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 Paul Baer > Sent: Friday, October 14, 2005 9:56 AM > To: r-help at stat.math.ethz.ch > Subject: [R] Setting working directory interactively within a function > > Is there anyway to have a function prompt the user for a working > directory, equivalent to file.choose()? > > --Paul > > ______________________________________________ > 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 >
Duncan Murdoch
2005-Oct-14 17:16 UTC
[R] Setting working directory interactively within a function
On 10/14/2005 12:55 PM, Paul Baer wrote:> Is there anyway to have a function prompt the user for a working > directory, equivalent to file.choose()?It's relatively easy to get a text prompt, but I don't think we've got a function that's equivalent to the Windows menu item "File|Change dir...". We probably should. Duncan Murdoch
Berton Gunter
2005-Oct-14 17:59 UTC
[R] Setting working directory interactively within a function
Oops. Thanks, all. Egg on my face. I forgot about that little detail (on Windows, anyway). However, you can still do it via dirname(file.choose()) to get the directory, on Windows,anyway, right? If that isn't implemented on another platform, than you could mimic the dirname() code by using gsub() to trim off the last file part of the path to get your directory. -- 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: Paul Baer [mailto:pbaer at berkeley.edu] > Sent: Friday, October 14, 2005 10:48 AM > To: Berton Gunter > Subject: RE: [R] Setting working directory interactively > within a function > > Hi Berton -I did check the docs first and tried this soloution, but > unfortunately on a Mac this doesn't work - you get a file choice > dialogue box, but it doesn't allow you to open (select) a directory, > only to choose a file. I suppose I should have noted this in my email. > > Thanks, > > --Paul > > >?setwd > >e.g. setwd(file.choose()) > > > >BTW, you could have found this on your own via help.search('working > >directory') . Base R has quite good docs -- you should try > them first. > > > >-- 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 Paul Baer > >> Sent: Friday, October 14, 2005 9:56 AM > >> To: r-help at stat.math.ethz.ch > >> Subject: [R] Setting working directory interactively > within a function > >> > >> Is there anyway to have a function prompt the user for a working > >> directory, equivalent to file.choose()? > >> > >> --Paul > >> > >> ______________________________________________ > >> 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 > >> > >
Gabor Grothendieck
2005-Oct-14 18:02 UTC
[R] Setting working directory interactively within a function
library(tcltk) setwd(tclvalue(tkchooseDirectory())) On 10/14/05, Paul Baer <pbaer at berkeley.edu> wrote:> Is there anyway to have a function prompt the user for a working > directory, equivalent to file.choose()?