diff --git a/R-package/R/xgb.DMatrix.R b/R-package/R/xgb.DMatrix.R index f6eeb041d..a6420d5ff 100644 --- a/R-package/R/xgb.DMatrix.R +++ b/R-package/R/xgb.DMatrix.R @@ -54,7 +54,7 @@ xgb.DMatrix <- function(data, info = list(), missing = NA, ...) { # internal helper method xgb.get.DMatrix <- function(data, label = NULL, missing = NA, weight = NULL) { inClass <- class(data) - if (inClass == "dgCMatrix" || inClass == "matrix") { + if ("dgCMatrix" %in% inClass || "matrix" %in% inClass ) { if (is.null(label)) { stop("xgboost: need label when data is a matrix") }