uniroot_noerr: Root finding without error

View source: R/uniroot_noerr.R

uniroot_noerrR Documentation

Root finding without error

Description

Runs the uniroot root finding algorithm and returns NULL instead of erroring if no solution is found.

Usage

uniroot_noerr(f, interval, ...)

Arguments

f

The function whose roots to find (must have one argument only)

interval

The range within which to search for a root

...

Additional parameters for uniroot

Details

The uniroot function errors if no solution is found, which is undesirable when looking for multiple roots across a range, or when looking for roots as part of a bigger pipeline. This function catches the error produced by uniroot if no solution is found and returns NULL instead.

Value

A root, or NULL

See Also

uniroot

Examples


f <- function(x) x^2 - 1
uniroot_noerr(f, c(-50, -30))


rscherrer/speciomx documentation built on March 28, 2023, 8:49 p.m.