Skip to contents

This function wraps tryCatch and suppresses some or all of the following:

Usage

silence(
  this_please,
  errors = TRUE,
  warnings = TRUE,
  messages = TRUE,
  output = FALSE
)

Arguments

this_please

Some code to run silently. If running multiple lines use {....}

errors

A logical value indicating if errors should be silenced. Default is TRUE.

warnings

A logical value indicating if warnings should be silenced. Default is TRUE.

messages

A logical value indicating if messages should be silenced. Default is TRUE.

output

A logical value indicating if output from print(), cat(), and writeLines() should be silenced. Default is TRUE.

Value

The output from this_please

Examples

silence(1 / 0)
silence(warning("test"))
silence(message("test"))
silence(print("test"))
#> [1] "test"
silence(cat("test"))
#> test
silence(1 + "a")