R/utils.R

Defines functions complement sample_idx as.integer.sample_idx

complement <- function(idx, n) {
  base::setdiff(idx, n)
}

sample_idx <- function(in_id = NULL, out_id = NULL, n = NULL) {
  list(in_id = in_id, out_id = out_id, n = n)
}

as.integer.sample_idx <- function(x, out = FALSE) {
  if (out) {
    x$out_id %||% complement(x$out_id, x$n)
  } else {
    x$in_id %||% complement(x$in_id, x$n)
  }
}
jrnold/ramsleep documentation built on May 29, 2019, 11:43 a.m.