if.error {berryFunctions}R Documentation

expressions/values conditional on whether tested expression returns an error.

Description

Does a given expression return an error? Return specific values/expressions for either case. Useful for loops when you want to easily control values based on errors that arise.

Usage

if.error(expr, error_true, error_false)

Arguments

expr

Expression to be tested for returning an error.

error_true

Value or expression to be executed if tested expression returns an error.

error_false

Value or expression to be executed if tested expression does not return an error.

Value

Returns value or expression stated in error_true or error_false, depending on whether the tested expression throws an error.

Author(s)

Nick Bultman, njbultman74@gmail.com, September 2020

See Also

is.error

Examples

if.error(  log(3),   "error", "no_error" )
if.error(  log(3),   "error", log(3)  )
if.error(  log(3),   log(6), "no_error" )
if.error(  log("a"), log(6), log(3) )


[Package berryFunctions version 1.20.1 Index]