catchWarning: Catch warnings

View source: R/catchWarning.r

catchWarningR Documentation

Catch warnings

Description

This is mainly used for code that either (a) generates a bunch of warnings, which makes it hard to find a warning that may have happened 78 warnings ago, or (b) generates a warning and an error, but it's hard to get at the warning because the error causes the code to crash before the warning is signalled.

Usage

catchWarning(expr)

Arguments

expr

An R expression

Examples

out <- catchWarning(log('a'))
out$value
out <- catchWarning(as.numeric(c('1', 'a')))
out
out <- catchWarning(1+1)
out

pbreheny/breheny documentation built on April 26, 2024, 10:40 a.m.