Hi, I have a xxx.R file. In order to run this file, I have to go to R, and type -- source("xxx.R"). Two questions: 1. How to run file xxx.R under DOS prompt instead of entering R environment? 2. There are several functions in file xxx.R, how to pass the arguments to the function when I try to run this file via source() function (or under DOS mode)? Thanks, Yu-Ling Wu __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 Tue, 13 Feb 2001 15:27:22 -0800 (PST), you wrote:>Hi, > >I have a xxx.R file. In order to run this file, I have >to go to R, and type -- source("xxx.R"). > >Two questions: >1. How to run file xxx.R under DOS prompt instead of >entering R environment?Try Rterm --slave <xxx.R Look in the R-intro manual for options other than --slave that you might want to use.>2. There are several functions in file xxx.R, how to >pass the arguments >to the function when I try to run this file via >source() function (or under DOS mode)?You can't, but you can add extra lines to the file with calls containing the arguments. For example, you might have myfunc <- function(x) { print(x) } in xxx.R. If you want to call myfunc(34), then first source the file, then execute myfunc(34). If doing it in batch mode, copy the file to a temp file, add the line "myfunc(34)" to the end, and execute the temp file. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 Tue, 13 Feb 2001, Yu-Ling Wu wrote:> Hi, > > I have a xxx.R file. In order to run this file, I have > to go to R, and type -- source("xxx.R"). > > Two questions: > 1. How to run file xxx.R under DOS prompt instead of > entering R environment?If you mean the Windows command line when running R under Windows, see the README: there is a program Rterm.exe. There is no version of R that runs under DOS.> 2. There are several functions in file xxx.R, how to > pass the arguments > to the function when I try to run this file via > source() function (or under DOS mode)?You call the functions with arguments in the file. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._