Skip to content

Commit 4fcb82d

Browse files
committed
refactor: replace length(levels(x)) with nlevels(x)
1 parent 994ab77 commit 4fcb82d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

R/crossvalidation.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
354354

355355
for(i in seq_along(namesFac)){
356356

357-
if(length(levels(droplevels(dathelp[[namesFac[i]]]))) !=
358-
length(levels(droplevels(dat_weights[[namesFac[i]]]))))
357+
if(nlevels(droplevels(dathelp[[namesFac[i]]])) !=
358+
nlevels(droplevels(dat_weights[[namesFac[i]]])))
359359
stop(paste0("The factor variable '", namesFac[i], "' has unobserved levels in the training data. ",
360360
"Make sure that training data in each fold contains all factor levels."))
361361

0 commit comments

Comments
 (0)