powered by
Internal-use wrapper for catching errors induced by stats::uniroot
safe.uniroot(f = NULL, interval = NULL)
If no error occurs, returns the solved root. If an error occurs, output a custom message.
The function for which the root is sought
A vector containing the end-points of the interval to be searched for the root
f <- function(x) x - 3 safe.uniroot(f, c(-10, 10))$root
Run the code above in your browser using DataLab