Let's start with some simple code:
require(randomForest)
randomForest(mpg~.,mtcars,ntree=10)
This builds a random forest of 10 trees.
What I want is to store the parameter in a list in than make the function call. Something like this:
require(randomForest)
l<-list(ntree=10)
randomForest(mpg~.,mtcars,l[[1]])
However, this does not work. The error message is:
Error in if (ncol(x) != ncol(xtest)) stop("x and xtest must have same number of columns") : argument is of length zero
This indicates that the parameter xtest=NULL of randomForest is set to 10 instead of ntree.
Why is that? How can I pass the parameter ntree as a list element?
Thank you.