title: R: Using the bigmemory library for classification with randomForest
body: <p>has anyone been able to set up a classification (not a regressions) using randomForest AND the bigmemory library. I am aware that the 'formula approach" cannot be used and we have to resort to the "x=predictors, y=response approach". It appears that the big memory library is unable to deal with a response vector that has categorical values (its a matrix, after all). In my case, I have two levels, both represented as characters.</p>
  
  <p>According to the bigmemory documentation..."A data frame will have character vectors converted to factors, and then all factors converted to numeric factor levels"</p>
  
  <p>Any suggested workarounds to get randomForest classification to work with bigmemory?</p>
  
  <pre><code>#EXAMPLE to problem
  library(randomForest)
  library(bigmemory)
  # Removing any extra objects from my workspace (just in case)
  rm(list=ls())
  
  #first small matrix
  small.mat &lt;- matrix(sample(0:1,5000,replace = TRUE),1000,5)
  colnames(small.mat) &lt;- paste("V",1:5,sep = "")
  small.mat[,5] &lt;- as.factor(small.mat[,5]) 
  small.rf &lt;- randomForest(V5 ~ .,data = small.mat, mtry=2, do.trace=100)
  print(small.rf)
  small.result &lt;- matrix(0,1000,1)
  small.result &lt;- predict(small.rf, data=small.mat[,-5])
  
  #now small dataframe Works!
  small.mat &lt;- matrix(sample(0:1,5000,replace = TRUE),1000,5)
  colnames(small.mat) &lt;- paste("V",1:5,sep = "")
  small.data &lt;- as.data.frame(small.mat)
  
  small.data[,5] &lt;- as.factor(small.data[,5]) 
  small.rf &lt;- randomForest(V5 ~ .,data = small.data, mtry=2, do.trace=100)
  print(small.rf)
  small.result &lt;- matrix(0,1000,1)
  small.result &lt;- predict(small.rf, data=small.data[,-5])
  
  
  #then big matrix Classification Does NOT Work :-(
  #----------------****************************----
  big.mat &lt;- as.big.matrix(small.mat, type = "integer")
  #Line below throws error, "cannot coerce class 'structure("big.matrix", package = "bigmemory")' into a data.frame"
  big.rf &lt;- randomForest(V5~.,data = big.mat, do.trace=10)
  
  #Runs without error but only regression
  big.rf &lt;- randomForest(x = big.mat[,-5], y = big.mat[,5], mtry=2, do.trace=100)
  print(big.rf)
  big.result &lt;- matrix(0,1000,1)
  big.result &lt;- predict(big.rf, data=big.mat[,-5])
  </code></pre>