title: random forest variable lengths differ
body: <p>I am trying to run RF using a feature as the response variable.  I am having trouble passing a string through a variable to be used as the response in RF.    First I try running RF on the string passed through a variable as the response and I am getting a "vector lengths differ error".  After this, I try just inputing the actual string(feature) as the response and it works fine.  Can you shed some light on why the variable lengths are differing?  Thanks.  </p>
  
  <pre><code>&gt; colnames(Data[1])
  [1] "feature1"
  &gt; rf.file = randomForest(formula =colnames(Data[1])~ ., data = Data, proximity = T,      importance = T, ntree = 500, nodesize = 3)
  Error in model.frame.default(formula = colnames(Data[1]) ~ .,  : 
    variable lengths differ (found for 'feature1')
  
  Enter a frame number, or 0 to exit   
  
  1: randomForest(formula = colnames(Data[1]) ~ ., data = Data, proximity = T, importance = T, ntree = 500, nodesize = 3)
  2: randomForest.formula(formula = colnames(Data[1]) ~ ., data = brainDataTrim, proximity = T, importance = T, ntree = 500, nodesize = 3)
  3: eval(m, parent.frame())
  4: eval(expr, envir, enclos)
  5: model.frame(formula = colnames(Data[1]) ~ ., data = Data, na.action = function (object, ...) 
  6: model.frame.default(formula = colnames(Data[1]) ~ ., data = Data, na.action = function (object, ...) 
  
  Selection: 0
  
  
  
  &gt; rf.file = randomForest(formula =feature1~ ., data = Data, proximity = T,      importance = T, ntree = 500, nodesize = 3)
  &gt; rf.file
  
  Call:
   randomForest(formula = feature1 ~ ., data = Data,      proximity = T, importance = T, ntree = 500, nodesize = 3) 
                 Type of random forest: regression
                       Number of trees: 500
  No. of variables tried at each split: 3
  
            Mean of squared residuals: 0.1536834
                      % Var explained: 34.21
  &gt; 
  </code></pre>