title: ROC curve from train/test set in caret R package
body: <p>I am working to plot a ROC curve of a model that uses a test/train set created with the caret R package. I either am not putting in the right data to plot or am missing something about the creation of my test/train set. Any insight??</p>
  
  <p>*Edited with correct answer</p>
  
  <pre><code>library(caret)
  library(mlbench)
  set.seed(506)
  data(whas)
  inTrain &lt;- createDataPartition(y = whas$bin.frail,
  p = .75, list = FALSE)
  str(inTrain)
  training &lt;- whas[ inTrain,]
  testing &lt;- whas[-inTrain,]
  nrow(training)
  nrow(testing)
  tc &lt;- trainControl("cv", 10, savePredictions=T)  #"cv" = cross-validation, 10-fold
  mod1 &lt;- train(bin.frail ~ ,
                        data      = training    ,
                        method    = "glm"    ,
                        family    = binomial ,
                        trControl = tc)
  
  library(pROC)
  mod1pred&lt;- predict(mod1, newdata=testingresponse="prob")
  plot(roc(testing$bin.frail, mod1pred[[2]]), print.auc=TRUE, col="red", 
  xlim=c(0,1))
  </code></pre>