Dear R People: I have used ./R --no-save -q -f e.in >stuff.out with great success on SUSE10.1 with R-2.7.1. My question is, please: is there a way to pass in a variable to the e.in file? I'm fairly sure that the answer is no, but thought I'd double check. Thanks in advance, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.com
Hi Erin, On Tue, 1 Jul 2008 18:49:02 -0500, "Erin Hodgess" <erinm.hodgess at gmail.com> wrote:> Dear R People: I have used> ./R --no-save -q -f e.in >stuff.out> with great success on SUSE10.1 with R-2.7.1.> My question is, please: is there a way to pass in a variable to the > e.in file? I'm fairly sure that the answer is no, but thought I'd > double check.Have a look at Rscript (included in R) or littler (a separate package) for scripting? I really like the latter. -- Seb
on 07/01/2008 06:49 PM Erin Hodgess wrote:> Dear R People: > > I have used > > ./R --no-save -q -f e.in >stuff.out > > with great success on SUSE10.1 with R-2.7.1. > > My question is, please: is there a way to pass in a variable to the > e.in file? I'm fairly sure that the answer is no, but thought I'd > double check. > > Thanks in advance, > Sincerely, > ErinErin, If I am correctly interpreting what you are looking to do, see: ?commandArgs which will let you access the command line as passed to R when invoked and then be able to parse out parameters. This, used in combination with the '--args' argument to R, can be useful. For example, let's say that your 'e.in' contains: ARGS <- commandArgs(trailingOnly = TRUE) as.numeric(ARGS[1]) ^ as.numeric(ARGS[2]) and you then use the following invocation of R from the command line: $ R --no-save --slave < e.in > stuff.out --args 3 5 The result generated is: $ cat stuff.out [1] 243 which of course is 3 ^ 5. HTH, Marc Schwartz
On 1 July 2008 at 18:49, Erin Hodgess wrote: | I have used | | ./R --no-save -q -f e.in >stuff.out | | with great success on SUSE10.1 with R-2.7.1. | | My question is, please: is there a way to pass in a variable to the | e.in file? I'm fairly sure that the answer is no, but thought I'd | double check. Start with help(commandArgs) but as Seb said, you probably want Rscript or littler. Dirk -- Three out of two people have difficulties with fractions.
commandArgs may do what you want. Best, luke On Tue, 1 Jul 2008, Erin Hodgess wrote:> Dear R People: > > I have used > > ./R --no-save -q -f e.in >stuff.out > > with great success on SUSE10.1 with R-2.7.1. > > My question is, please: is there a way to pass in a variable to the > e.in file? I'm fairly sure that the answer is no, but thought I'd > double check. > > Thanks in advance, > Sincerely, > Erin > > >-- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke at stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu