title: tune() function e1071 / libsvm -error with rpart
body: <p>I am trying to tune <code>rpart</code>. I have already split my data into a training and cv set. The <code>tune.rpart</code> convenience function doesn't seem to have a a way to specify a cv set. so I am using the regular <code>tune()</code> function.</p>
  
  <p>I have 595 potential variables in my dataset, so I don't want to specify using a formula. I get the following error when I do this  </p>
  
  <pre><code>Error in tune(rpart, train.x = trainset[, -1], train.y = trainset[, 1],  : 
  Dependent variable has wrong type!
  In addition: Warning message:
  In if (y) ans$y &lt;- Y :
  the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>load('train.dat')
  load('cv.dat')
  trainset$class&lt;-factor(trainset$class)
  cvset$class&lt;-factor(cvset$class)
  
  rpart.tune&lt;-tune(rpart,train.x= trainset[,-1], train.y=trainset[,1],
             validation.x=cvset[,-1], validation.y=cvset[,1],
               ranges = list(
                 cp = c(0.002,0.005,0.01,0.015,0.02,0.03)),
             tunecontrol = tune.control(sampling = "fix"))
  </code></pre>
  
  <p>Data is available at:
  <a href="https://docs.google.com/folder/d/0B2_rKFnvrjMAM3FGbnFvZm5laUk/edit" rel="nofollow">https://docs.google.com/folder/d/0B2_rKFnvrjMAM3FGbnFvZm5laUk/edit</a></p>