R/checkTaskSubset.R

Defines functions checkTaskSubset

# @template arg_subset
# @param size [int(1)]\cr size of the dataset to subset
# @return numeric vector of subset indices
checkTaskSubset = function(subset = NULL, size) {
  assertCount(size)
  if (is.null(subset)) {
    seq_len(size)
  } else if (is.logical(subset)) {
    subset = which(subset)
    assertInteger(subset, min.len = 1L, upper = size)
  } else {
    asInteger(subset, min.len = 1L, any.missing = FALSE, lower = 1L, upper = size)
  }
}

Try the mlr package in your browser

Any scripts or data that you put into this service are public.

mlr documentation built on June 22, 2024, 10:51 a.m.