R: Slice a dataset

slice {lightgbm} | R Documentation

## Slice a dataset

### Description

Get a new `lgb.Dataset` containing the specified rows of original `lgb.Dataset` object

### Usage

    slice(dataset, ...)

    ## S3 method for class 'lgb.Dataset'
    slice(dataset, idxset, ...)

### Arguments

`dataset` | Object of class `lgb.Dataset`
`...` | other parameters (currently not used)
`idxset` | an integer vector of indices of rows needed

### Value

constructed sub dataset

constructed sub dataset

### Examples

    data(agaricus.train, package = "lightgbm")
    train <- agaricus.train
    dtrain <- lgb.Dataset(train$data, label = train$label)

    dsub <- lightgbm::slice(dtrain, seq_len(42L))
    lgb.Dataset.construct(dsub)
    labels <- lightgbm::getinfo(dsub, "label")

[Package lightgbm version 3.1.1 Index]