[R] run R under DOS prompt
Duncan Murdoch
dmurdoch at pair.com
Wed Feb 14 02:18:25 CET 2001
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list