dim.xgb.DMatrix: Dimensions of xgb.DMatrix

Description Usage Arguments Details Examples

View source: R/xgb.DMatrix.R

Description

Returns a vector of numbers of rows and of columns in an xgb.DMatrix.

Usage

1
2
## S3 method for class 'xgb.DMatrix'
dim(x)

Arguments

x

Object of class xgb.DMatrix

Details

Note: since nrow and ncol internally use dim, they can also be directly used with an xgb.DMatrix object.

Examples

1
2
3
4
5
6
7
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)

stopifnot(nrow(dtrain) == nrow(train$data))
stopifnot(ncol(dtrain) == ncol(train$data))
stopifnot(all(dim(dtrain) == dim(train$data)))

xgboost documentation built on April 22, 2021, 5:06 p.m.