xgb.DMatrix.hasinfo: Check whether DMatrix object has a field

View source: R/xgb.DMatrix.R

xgb.DMatrix.hasinfoR Documentation

Check whether DMatrix object has a field

Description

Checks whether an xgb.DMatrix object has a given field assigned to it, such as weights, labels, etc.

Usage

xgb.DMatrix.hasinfo(object, info)

Arguments

object

The DMatrix object to check for the given info field.

info

The field to check for presence or absence in object.

See Also

xgb.DMatrix(), getinfo.xgb.DMatrix(), setinfo.xgb.DMatrix()

Examples

x <- matrix(1:10, nrow = 5)
dm <- xgb.DMatrix(x, nthread = 1)

# 'dm' so far does not have any fields set
xgb.DMatrix.hasinfo(dm, "label")

# Fields can be added after construction
setinfo(dm, "label", 1:5)
xgb.DMatrix.hasinfo(dm, "label")

xgboost documentation built on Dec. 3, 2025, 5:06 p.m.