tryel: A more intuitive take on base R's try function.

Description Usage Arguments Examples

View source: R/comfy-functions.R

Description

Combines the benefits of try and else into one easy-to-use function.

Usage

1
tryel(expr, el, return_error = FALSE)

Arguments

expr

The expression to be attempted.

el

The return if expr fails. Can be a value or alternate function.

return_error

Should the error message of a failed expr be returned? Defaults to FALSE.

Examples

1
2
3
4
bad_fun <- function() log("hello")
tryel(bad_fun(), 100)
good_fun <- function() log(10)
tryel(bad_fun(), good_fun())

tomathon-io/comfy documentation built on June 20, 2020, 1 a.m.