title: Random forest bootstrap training and forest generation
body: <p>I have a huge training data for random forest (dim: 47600811*9). I want to take multiple (let's say 1000) bootstrapped sample of dimension 10000*9 (taking 9000 negative class and 1000 positive class datapoints in each run) and iteratively generate trees for all of them and then combine all those trees into 1 forest.
  A rough idea of required code is given below. Can anbody guide me how can I generate random sample with replacement from my actual trainData and optimally generate trees for them iteratively? It will be great help. Thanks</p>
  
  <pre><code>library(doSNOW)
  library(randomForest)
  cl &lt;- makeCluster(8)
  registerDoSNOW(cl)
  
  for (i=1:1000){
  B &lt;- 1000 
  U &lt;- 9000 
  dataB &lt;- trainData[sample(which(trainData$class == "B"), B,replace=TRUE),] 
  dataU &lt;- trainData[sample(which(trainData$class == "U"), U,replace=TRUE),] 
  subset &lt;- rbind(dataB, dataU)
  </code></pre>
  
  <p>I am not sure if it is the optimal way of producing a subset again and again (1000 times) from actual trainData. </p>
  
  <pre><code>rf &lt;- foreach(ntree=rep(125, 8), .packages='randomForest') %dopar% {
    randomForest(subset[,-1], subset$class, ntree=ntree)
  }
  }
  crf &lt;- do.call('combine', rf)
  print(crf)
  stopCluster(cl)
  </code></pre>