Skip to contents

Output written to stdout during the evaluation of x are suppressed. Messages, warnings, and errors are not suppressed.

Usage

quiet(x)

Arguments

x

An expression.

Value

The value of x, returned invisibly.

Examples

#----------------------------------------------------------------------------
# quiet() examples
#----------------------------------------------------------------------------
library(bkbase)

bad_fun <- function(x) {
  cat("Unwanted output\n")
  x
}

# Direct call writes to stdout and returns the value:
bad_fun(2)
#> Unwanted output
#> [1] 2

# Wrapped call suppresses stdout and returns invisibly:
quiet(bad_fun(2))

# The return value is preserved:
result <- quiet(bad_fun(2))
result
#> [1] 2