[R] Loop with string variable AND customizable "summary" output
Vladimir Eremeev
wl2776 at gmail.com
Mon Jan 29 17:07:22 CET 2007
That is
C.Rosa wrote:
>
> for (i in c("UK","USA"))
> output{i}<-summary(lm(y{i} ~ x{i}))
>
for (i in c("UK","USA")) {
lm.txt<-paste("output",i,"<-","lm(","y",i,"x",i,")",sep="") # 1. produce a
character string containing needed expression
eval(parse(text=lm.txt)) #
2. parse and evaluate it
}
--
View this message in context: http://www.nabble.com/-R--Loop-with-string-variable-AND-customizable-%22summary%22-output-tf3136358.html#a8692041
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list