Learn R Programming

powertools (version 1.0.0)

safe.uniroot: Internal-use wrapper for catching errors induced by stats::uniroot

Description

Internal-use wrapper for catching errors induced by stats::uniroot

Usage

safe.uniroot(f = NULL, interval = NULL)

Value

If no error occurs, returns the solved root. If an error occurs, output a custom message.

Arguments

f

The function for which the root is sought

interval

A vector containing the end-points of the interval to be searched for the root

Examples

Run this code
f <- function(x) x - 3
safe.uniroot(f, c(-10, 10))$root

Run the code above in your browser using DataLab