[R] creating a list of lists
Paul Boutros
paul.boutros at utoronto.ca
Sun Jan 7 05:22:15 CET 2007
Hello,
I'm trying to create a series of randomForest objects, basically in a
loop like this:
forests <- list();
for (level in 1:10) {
# do some other things here
# create a random forest
forest <- randomForest(
x = x.level,
y = z.level,
ntree = trees
);
forests <- c(forests, forest);
}
But instead of creating a list of 10 forests, this creates a list of
180 elements, 18 for each forest. Is there a way to create a list of
randomForest objects for use later on in code like:
for (forest in forests) {
values <- predict(forest, data);
# do things with these predicted values
}
Sincerely,
Paul
More information about the R-help
mailing list