R/utils-stealth_sample.int.R

Defines functions stealth_sample.int

## A version of base::sample.int() that does not change .Random.seed
stealth_sample.int <- function(...) {
  oseed <- .GlobalEnv$.Random.seed
  on.exit({
    if (is.null(oseed)) {
      rm(list = ".Random.seed", envir = .GlobalEnv, inherits = FALSE)
    } else {
      .GlobalEnv$.Random.seed <- oseed
    }
  })
  suppressWarnings(sample.int(...))
}

Try the progressr package in your browser

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

progressr documentation built on Oct. 18, 2026, 5:08 p.m.