[R] How identify args into R, sent from a command line.
Ortiz, John
OrtizJ at si.edu
Wed Mar 23 21:15:55 CET 2011
Hi,
For example, I have several variables in php, like
var1 = 1, 2, 3, 5, 6
var2 = 3, 1, 8
var3 = 8, 10, 4, 0, 9, 1
I sent the arguments to R, with this line:
'/usr/bin/R --vanilla --slave --args '.$var1.' '.$var2.' '.$var3.' < script.r'
In my "script.r" I can read the arguments whit this line:
args=(commandArgs(TRUE))
args=as.numeric(args)
args = 1, 2, 3, 5, 6, 3, 1, 8, 8, 10, 4, 0, 9, 1
I'm looking the way to catch into de R, just the arguments var2
something like
args = 3, 1, 8
I know that is possible index with
args[6:8]
But, the problem is that the length of (var1, var2, var3) might be variable,
not always var2 is args[6:8]
Thanks in advance,
John
More information about the R-help
mailing list