This function subsets a custom dataset object based on specified row indices and optional column names.
If column names are not specified, it defaults to using all columns. The function checks if the provided
column names exist in the dataset and whether they include the target variable, which cannot be removed.
Usage
# S3 method for Dataset
[(x, i, j = NULL, ...)
Arguments
- x
A Dataset object.
- i
row indices or nothing.
- j
covariate names or nothing.
- ...
Other arguments passed to function
Value
A object of type 'Dataset.
Examples
cars.data <- Dataset(cars, target = "dist")
cars.data[c(1, 2, 3), "dist"]
#> Dataset "cars", predicting "dist" (Regression)
#> [1] 2 10 4