Hello all. I have this code: myLOOCV <- function(myformula, data) { Y <- all.vars(myformula)[1] Scores<- numeric(length(data[,1])) for (i in 1:length(data[,1])) { train <- data[-i,] test <- data[i,] myModel <- lrm(myformula, train) Scores[i] <- predict(myModel, test,type="mean") } factor(Scores,labels=levels(data[,Y])) } When I call the method myLOOCV, myLOOCV(value, data), I have this error: Error in factor(Scores, labels = levels(data[, Y])) : invalid 'labels'; length 4 should be 1 or 180 I don't understand it! Could anyone solve it? Thanks in advance. [[alternative HTML version deleted]]