title: pruning tree with caret library returns complex trees
body: <p>I'm using the caret package for a tree model. I understood that caret uses CV to find the optimal tuning parameter  for pruning the tree. </p>
  
  <p>This is the code I use:</p>
  
  <pre><code>id2 &lt;- sample(1:nrow(data),2/3*nrow(data))
  #learn
  app &lt;- data[id2,]
  #test
  test &lt;- data[-id2,]
  
  ctrl&lt;-trainControl(method="cv", number=8,classProbs=TRUE, summaryFunction=twoClassSummary)
  mod0 &lt;- train(class~., data=app,method="rpart",trControl=ctrl,metric="ROC")
  plot(mod0)
  plot(mod0$finalModel,uniform=TRUE,margin=.1);text(mod0$finalModel,cex=0.8)
  </code></pre>
  
  <p>Here is my data:  <a href="https://drive.google.com/open?id=1xrCXTLqKvGiGeo2X0Y1DvoSKvzbYFnyccLimceDIbZg" rel="nofollow">https://drive.google.com/open?id=1xrCXTLqKvGiGeo2X0Y1DvoSKvzbYFnyccLimceDIbZg</a></p>
  
  <p>But everytime I run the code I get trees of different complexities (because of CV?) and the tree is not really pruned but very complex and a lot of terminal nodes. </p>
  
  <p>How can I get a less complex tree ? </p>