Learn R Programming

FastUtils (version 0.2.1)

quietly: Suppress Messages and Output

Description

This function suppresses messages and captures output from an expression. Note that this does NOT return the result of the expression! It is intended to be used in contexts where certain operations with side effects are performed but the verbosity should be suppressed.

Usage

quietly(e)

Value

The result of the expression with messages suppressed and output captured.

Arguments

e

An expression to evaluate.

Examples

Run this code

quietly(print(1))

quietly({
    print(1)
    print(2)
    print(3)
})

a <- 1
quietly({
    a <- a + 1
    print(a)
})
print(a)
#> 2

Run the code above in your browser using DataLab