[R] using var from bash in R script
dood
arulspam at gmail.com
Wed Jan 4 23:43:52 CET 2012
Marc Schwartz-3 wrote
>
> See ?as.formula and ?paste
>
> Something along the lines of the following should work:
>
> Args <- c("one", "two", "three")
>
>> Args
> [1] "one" "two" "three"
>
>> paste(Args[1], "~", Args[2])
> [1] "one ~ two"
>
>> as.formula(paste(Args[1], "~", Args[2]))
> one ~ two
>
> Then use:
>
> summary(lm(as.formula(paste(Args[1], "~", Args[2]))))
>
>
> If 'one', 'two' and 'three' are columns in a data frame (say 'DF'), you
> will want to use the data argument in the call to lm():
>
> summary(lm(as.formula(paste(Args[1], "~", Args[2])), data = DF))
>
Thanks, that works!!!!!
--
View this message in context: http://r.789695.n4.nabble.com/using-var-from-bash-in-R-script-tp4262857p4263235.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list