Re: [R] Loop with string variable AND customizable "summary" output

From: Vladimir Eremeev <>
Date: Mon 29 Jan 2007 - 16:07:22 GMT

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:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Jan 30 03:12:37 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 29 Jan 2007 - 16:30:42 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.