Hi folks: How do I get shell() or system() to run external programs in a particular directory (different from the current R working directory)?> version_ platform i386-pc-mingw32 arch x86 os Win32 system x86, Win32 status major 1 minor 3.0 year 2001 month 06 day 22 language R>TIA. Rajiv. -------- Rajiv Prasad Postdoctoral Research Associate, Hydrology Group Pacific Northwest National Laboratory, P.O. Box 999, MSIN K9-33 Richland, WA 99352 Voice: (509) 375-2096 Fax: (509) 372-6089 Email: rajiv.prasad at pnl.gov -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 28 Nov 2001, Prasad, Rajiv wrote:> Hi folks: > > How do I get shell() or system() to run external programs in a particular > directory (different from the current R working directory)?Give the full path.> > > version > _ > platform i386-pc-mingw32 > arch x86 > os Win32 > system x86, Win32 > status > major 1 > minor 3.0 > year 2001 > month 06 > day 22 > language R > > > > TIA. > > Rajiv. > -------- > Rajiv Prasad > Postdoctoral Research Associate, Hydrology Group > Pacific Northwest National Laboratory, P.O. Box 999, MSIN K9-33 > Richland, WA 99352 > Voice: (509) 375-2096 Fax: (509) 372-6089 Email: rajiv.prasad at pnl.gov > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -----Original Message----- > From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] > Sent: Wednesday, November 28, 2001 12:13 PM > To: Prasad, Rajiv > Cc: R-Help (E-mail) > Subject: Re: [R] shell()/system() question > > > On Wed, 28 Nov 2001, Prasad, Rajiv wrote: > > > Hi folks: > > > > How do I get shell() or system() to run external programs > > in a particular > > directory (different from the current R working directory)? > > Give the full path.Guess I did not specify the problem entirely. Apologies. I'll try again. The "program" that I am trying to run accesses files stored in the same directory where it is run, and produces output to stdout, which I am trying to capture directly into R via shell(). This works well if the current working directory in R is the same as where the program to be run is located. If not, the program fails since it cannot access its supporting data files. Since my earlier mail, I figured a workaround, using getwd() and setwd() to temporarily change the R working directory, run the program using shell(), and reset the R working directory to where it originally was. Works via a wrapper function. Just wondering if shell() or system() may be provided with a "wd" argument? Not a big deal, since the wrapper is easy to write. Thanks for your quick reply. Rajiv. -------- Rajiv Prasad Postdoctoral Research Associate, Hydrology Group Pacific Northwest National Laboratory, P.O. Box 999, MSIN K9-33 Richland, WA 99352 Voice: (509) 375-2096 Fax: (509) 372-6089 Email: rajiv.prasad at pnl.gov -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._