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

From: Vladimir Eremeev <wl2776_at_gmail.com>
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: 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.
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.