-
Notifications
You must be signed in to change notification settings - Fork 631
Open
Description
caret/pkg/caret/R/createDataPartition.R
Line 122 in c98cc1a
| xtab <- table(y) |
As I'm finding in work towards #1382, missing inputs are handled a bit inconsistently by createDataPartition():
library(withr)
# y is numeric, missing --> error
createDataPartition(c(NA, 1))
# Error in quantile.default(y, probs = seq(0, 1, length = groups)) :
# missing values and NaN's not allowed if 'na.rm' is FALSE
# y is character, level with only one observation --> warning
with_seed(78458, createDataPartition(c("a", "b", "b")))
# $Resample1
# [1] 1 3
# Warning message:
# In createDataPartition(c("a", "b", "b")) :
# Some classes have a single record ( a ) and these will be selected for the sample
# y is character, missing level has only one observation --> no warning
with_seed(78458, createDataPartition(c(NA, "b", "b")))
# $Resample1
# [1] 1 3What is the proper handling of missing y? Should we just error if y has any missing observations? That would certainly make the migration away from dlply() simpler (c.f. 5805d30).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels