[R] Re-sent to correct list: passing parameters
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Nov 9 18:00:39 CET 2001
Thomas Lumley <tlumley at u.washington.edu> writes:
> On Fri, 9 Nov 2001, Shravan Vasishth wrote:
>
> > Hi,
> >
> > My apologies for sending this message earlier to the wrong list (next
> > time I'll wait till I'm fully awake).
> >
> > I'm a new R user. I want to do the following:
> >
> > I want to pass a filename to R repeatedly (about 400 times) in order to
> > do a repetitive task (calculating regressions).
> >
> <snip>
> > It works, but this is a really ugly hack, so my question is: is there a
> > better way to do this? For example, is there some way to pass a
> > filehandle as a parameter to R? From reading the manuals and old news
> > posts and responses, it seems the answer is no. I'm thinking of a
> > command like
> >
> > R --silent -slave < source.R $f >> outfile.test
> >
> > where $f will be used as the variable for the file to be converted to an
> >
> > object ("foo" in my toy example above).
>
> THe commandArgs() function reports the arguments that R was called with.
Also, things can be made somewhat cleaner by utilizing the fact that
substitution takes place in here scripts, e.g.
#!/bin/sh
for i in *.c ; do R --vanilla --quiet << EOF
print("$i")
EOF
However, the question is whether it wouldn't be better to have loop
coded internally to R.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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