title: ROC curve in R using ROCR package
body: <p>Can someone explain me please how to plot a ROC curve with ROCR.
  I know that I should first run:</p>
  
  
  
  <pre><code>prediction(predictions, labels, label.ordering = NULL)
  </code></pre>
  
  <p>and then: </p>
  
  <pre><code>performance(prediction.obj, measure, x.measure="cutoff", ...)
  </code></pre>
  
  <p>I am just not clear what is meant with prediction and labels. I created a model with ctree and cforest and I want the ROC curve for both of them to compare it in the end. In my case the class attribute is y_n, which I suppose should be used for the labels. But what about the predictions? Here are the steps of what I do (dataset name= bank_part):</p>
  
  <pre><code>pred&lt;-cforest(y_n~.,bank_part)
  tablebank&lt;-table(predict(pred),bank_part$y_n)
  prediction(tablebank, bank_part$y_n)
  </code></pre>
  
  <p>After running the last line I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Error in prediction(tablebank, bank_part$y_n) : 
  Number of cross-validation runs must be equal for predictions and labels.
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>Here's another example: I have the training dataset(bank_training) and testing dataset(bank_testing) and I ran a randomForest as below:</p>
  
  <pre><code>bankrf&lt;-randomForest(y~., bank_training, mtry=4, ntree=2,    
  keep.forest=TRUE,importance=TRUE) 
  bankrf.pred&lt;-predict(bankrf, bank_testing, type='response')
  </code></pre>
  
  <p>Now the bankrf.pred is a factor object with labels c=("0", "1"). Still, I don't know how to plot ROC, cause I get stuck to the prediction part. Here's what I do</p>
  
  <pre><code>library(ROCR) 
  pred&lt;-prediction(bankrf.pred$y, bank_testing$c(0,1) 
  </code></pre>
  
  <p>But this is still incorrect, cause I get the error message</p>
  
  <pre class="lang-none prettyprint-override"><code>Error in bankrf.pred$y_n : $ operator is invalid for atomic vectors
  </code></pre>