Skip to contents

This function is useful for when you want to evaluate an expression, but you want to catch any errors and return a default value instead. Note the error message will be printed as a warning as the name of the function suggests.

Usage

cautiously(.f, otherwise = NULL)

Arguments

.f

A function to modify. See as_function() for details.

otherwise

A value to return if the expression throws an error.

Value

A function that evaluates the expression and returns the result or the default value if an error is thrown.