Skip to content

Commit e166942

Browse files
authored
[R] error out on factors passed to DMatrix (#11810)
1 parent 9255b9c commit e166942

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

R-package/R/xgb.DMatrix.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,9 @@ setinfo.xgb.DMatrix <- function(object, name, info) {
10631063
if (name == "label") {
10641064
if (NROW(info) != nrow(object))
10651065
stop("The length of labels must equal to the number of rows in the input data")
1066+
if (is.factor(info)) {
1067+
stop("'label' must be a numeric variable.")
1068+
}
10661069
.Call(XGDMatrixSetInfo_R, object, name, info)
10671070
return(TRUE)
10681071
}

0 commit comments

Comments
 (0)