Learn R Programming

lightgbm (version 4.5.0)

dim.lgb.Dataset: Dimensions of an lgb.Dataset

Description

Returns a vector of numbers of rows and of columns in an lgb.Dataset.

Usage

# S3 method for lgb.Dataset
dim(x)

Value

a vector of numbers of rows and of columns

Arguments

x

Object of class lgb.Dataset

Details

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

Examples

Run this code
# \donttest{
setLGBMthreads(2L)
data.table::setDTthreads(1L)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)

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

Run the code above in your browser using DataLab