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

Description Usage Arguments Examples

View source: R/wordly_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("potato")
tryel(bad_fun(), 100)
good_fun <- function() log(10)
tryel(bad_fun(), good_fun())

tomathon-io/wordly documentation built on June 15, 2020, 12:41 a.m.