Learn R Programming

EloSteepness (version 0.5.0)

catch_warnings: catch warnings alongside results without returning warning

Description

helper function

Usage

catch_warnings(expr)

Value

a list where the first entry is the result of expr and the second provides information about warnings

Arguments

expr

an R expression to evaluate

Examples

Run this code
log(3)
catch_warnings(log(3))

# produces warning
# log(-3)
# catch it
catch_warnings(log(-3))

# produces error
# log("x")
# catch it
catch_warnings(log("x"))

Run the code above in your browser using DataLab