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

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Tue, 20 May 2008 13:30:58 +0000 (UTC)

Angel Marley <angel_nauti <at> yahoo.com> 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.

Dieter

library(tree)
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")
rm(trees)
# Reload
load("trees.Rdata")
## Well... add the decoration
plot.tree(trees[["Length"]])



R-help_at_r-project.org 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 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive