Merge pull request #229 from nagadomi/fix_group_check_in_r

Fix length check in utils.R
This commit is contained in:
Tianqi Chen 2015-04-09 09:02:31 -07:00
commit 7975dd03a9

View File

@ -36,8 +36,8 @@ xgb.setinfo <- function(dmat, name, info) {
return(TRUE) return(TRUE)
} }
if (name == "group") { if (name == "group") {
if (length(info)!=xgb.numrow(dmat)) if (sum(info)!=xgb.numrow(dmat))
stop("The length of groups must equal to the number of rows in the input data") stop("The sum of groups must equal to the number of rows in the input data")
.Call("XGDMatrixSetInfo_R", dmat, name, as.integer(info), .Call("XGDMatrixSetInfo_R", dmat, name, as.integer(info),
PACKAGE = "xgboost") PACKAGE = "xgboost")
return(TRUE) return(TRUE)