HI,
Using the example in ?combine
library(randomForest)
rf1 <- randomForest(Species ~ ., iris, ntree=50, norm.votes=FALSE)
      rf2 <- randomForest(Species ~ ., iris, ntree=50, norm.votes=FALSE)
      rf3 <- randomForest(Species ~ ., iris, ntree=50, norm.votes=FALSE)
      rf.all <- combine(rf1, rf2, rf3)
lst1<- list(rf1,rf2,rf3)

rf.allL<- do.call(`combine`,lst1)
#or
rf.allL<- Reduce(`combine,lst1)
 identical(rf.all,rf.allL)
#[1] TRUE
A.K.


Is there a quick and easy way to pass randomForest objects contained in a list 
into the combine() function? 

As a result of calling randomForest through lapply(), I now have 10 
randomForests in a list (rfors) 

I want to combine all 10 of them. Understandably combine(rfors) 
doesn't work as it doesn't recognise the individual forests within the 
list. I have spend quite sometime messing around with unlist(), lapply()
 and apply() to try and extract the information in a suitable format but
 to no avail. The only thing that works is combine(rfors[[1]], 
rfors[[2]] ...etc). 

This is a bit cumbersome though, not least because the number of
 random forests I'll need to combine is likely to change. Any sleek and 
elegant solution to this someone can suggest? 

Thanks in advance for any help. 

Anna

______________________________________________
[email protected] 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.

Reply via email to