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.

______________________________________________
R-help@stat.math.ethz.ch 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