R/tools.R

Defines functions sample_seed require_package tempfile

tempfile <- function(name="unnamed") {
  base::tempfile(paste0("coala-", Sys.getpid(), "-", name, "-"))
}

require_package <- function(pkg) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    stop("Please install package '", pkg, "'", call. = FALSE)
  }
  invisible(TRUE)
}

sample_seed <- function(n = 1, for_ms = FALSE) {
  max_value <- ifelse(for_ms, 65536, 1e9)
  sample.int(max_value, n)
}

Try the coala package in your browser

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

coala documentation built on Jan. 5, 2023, 5:11 p.m.