Re: [R] how to save many trees within a loop?

From: Dieter Menne <>
Date: Tue, 20 May 2008 13:30:58 +0000 (UTC)

Angel Marley <angel_nauti <at>> writes:
> I would like to save many trees created in a loop as
> different ones. I can plot them, but I can not get the
> whole tree properties saved. I paste the script below
> for (i in 1:7){#loop para hacer arb
> arb=arb[i]#contador
> arb=tree(GF[,i]~Temp+Area+ISS+Zmix+Kd+Alk+DIN+SRP+RSi+CLA+Chloa,
> data=GF)#
> plot.tree(arb); tit=colnames(GF[i]);title(tit);
> text(arb,digits =2);#dig significativos

Save the for.. results in a list, and save/load the list. Please, provide a self-running examples next time.


trees = list()
# Simple for - replacement
trees[["Length"]]= tree(Species ~Sepal.Length+Petal.Length, iris) trees[["Width"]]= tree(Species ~Sepal.Width+Petal.Width, iris) save(trees, file="trees.Rdata")
# Reload
## Well... add the decoration
plot.tree(trees[["Length"]]) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 20 May 2008 - 13:34:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 14:30:38 GMT.

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

list of date sections of archive