R/util_suppress_output.R

Defines functions util_suppress_output

Documented in util_suppress_output

#' Suppress any output to `stdout` using [sink()]
#'
#' @param expr [expression()]
#'
#' @return [invisible()] result of `expr`
#'
#' @family process_functions
#' @keywords internal
util_suppress_output <- function(expr) {
  sink(type = "output", file = nullfile())
  on.exit((function(){sink()})())
  invisible(force(eval(expr, envir = parent.frame())))
}

Try the dataquieR package in your browser

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

dataquieR documentation built on May 29, 2024, 7:18 a.m.