I am trying to create ROC curves for different diagnostic tests using the ROCR package but keep getting an error message for the last two diagnostic tests:
test6 <- prediction(x[,37], x[,48])
Error in prediction(x[, 37], x[, 48]) :
Number of classes is not equal to 2.
ROCR currently supports only evaluation of binary classification tasks.
Five other tests run without errors. I have checked lengths of prediction and labels and they are the same. Using [sapply(c(is.vector, is.matrix, is.list, is.data.frame), do.call, list(x))]shows FALSE FALSE TRUE TRUE, but converting the data frame to a vector or a matrix does not solve the error:
x <-as.data.frame(read.csv("datafile.csv", header=T))
test1 <- prediction(x[,18], x[,48])
test2 <- prediction(x[,11], x[,48])
test3 <- prediction(x[,13], x[,48])
test4 <- prediction(x[,20], x[,48])
test5 <- ROCR::prediction(x[,31], x[,48])
test6 <- prediction(x[,37], x[,48])
Thank you in advance for any advice!