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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to