I have a list of data.frames that I would like to run through caret's confusionMatrix function resulting in a list of confusion matrices, one confusion matrix for each data.frame.
Each data.frame has 14 variables with the two last variables containing the reference data (variable 13) and predicted data (variable 14).
Example below:
d1 <- data.frame(y1 = c(1,2,3,4,5,5,5,5,5), y2 = c(1,1,1,2,2,2,3,3,3), y3 = c(1,1,2,2,2,2,3,3,1))
d2 <- data.frame(y1 = c(3,2,1,4,5,6,7,5,4), y2 = c(1,1,1,1,2,2,2,3,3), y3 = c(1,2,1,1,2,3,3,3,3))
my.list <- list(d1, d2)
CM <- lapply(my.list, function(x) confusionMatrix(data = x[,3],
reference = x[,2],
positive = 'yes'))