[R] Executing Command on Multiple R Objects

patze003 patze003 at umn.edu
Mon Nov 15 22:43:40 CET 2010


Hello Everyone - 

I want to print a number of results from lme function objects out to a txt
file.  How could I do this more efficiently than what you see here:

out2 <- capture.output(summary(mod2a))
out3 <- capture.output(summary(mod3))
out4 <- capture.output(summary(mod5))
out5 <- capture.output(summary(mod6))
out6 <- capture.output(summary(mod7))
cat(out2,file="out.txt",sep="\n",append=TRUE)
cat(out3,file="out.txt",sep="\n",append=TRUE)
cat(out4,file="out.txt",sep="\n",append=TRUE)
cat(out5,file="out.txt",sep="\n",append=TRUE)
cat(out6,file="out.txt",sep="\n",append=TRUE)
cat(third,file="out.txt",sep="\n",append=TRUE)


Here's an example of what I tried, but didn't work.

for (i in ls(pat = "mod"))
	{ out <- capture.output(summary[[i]])
		cat(out, file = "results_paired.txt", sep = "\n", append = TRUE)
		}
-- 
View this message in context: http://r.789695.n4.nabble.com/Executing-Command-on-Multiple-R-Objects-tp3043871p3043871.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list