Skip to content

Commit 4f668f1

Browse files
Merge pull request #49 from m-muecke/nlevels
refactor: replace `length(levels(x))` with `nlevels(x)`
2 parents 7ba993e + 4fcb82d commit 4f668f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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)