Dear List,
My question is whether it is possible (and if so, how) to enter values
into R vectors (R_OUTFILE, and R_INFILE in my example below) from the
command line. In particular, I would like to run R, as a BATCH job,
from a shell script, such as the following:
while read inputfile_name outputfile_name; do
R_OUTFILE=$outputfile_name
R_INFILE=$inputfile_name
R BATCH infile.R
done
with, for example, the following infile.R able to use the variables,
R_OUTFILE, and R_INFILE.
sink(R_OUTFILE)
x<-read.table(R_INFILE)
mode(x)="numeric"
library(cluster)
a<-agnes(x,T)
a$order
a$height
sink()
q("no")
I suppose I could write a different infile.R for each pass through the
shell script while-loop, but I don't want to do that if it's avoidable.
Thank You for Any Help You are Able to Provide,
Laura Drake
ladrake at ece.nwu.edu
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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, 1 Sep 1999, Laura Drake wrote:> Dear List, > > My question is whether it is possible (and if so, how) to enter values > into R vectors (R_OUTFILE, and R_INFILE in my example below) from the > command line. In particular, I would like to run R, as a BATCH job, > from a shell script, such as the following:yes. Use getenv() wompom% setenv R_INFILE foobar R is a collaborative project with many contributors. Type "?contributors" for a list. Type "demo()" for some demos, "help()" for on-line help, or "help.start()" for a HTML browser interface to help. Type "q()" to quit R.> getenv("R_INFILE")R_INFILE "foobar"> sink(getenv("R_INFILE"))etc at least under Unix (which I presume is where you are if you want to use a shell script) Thomas Lumley Assistant Professor, Biostatistics University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._