powered by
Drop-in replacement for purrr::possibly that returns a default value when an error occurs instead of throwing the error.
s_possibly(.f, otherwise, quiet = TRUE)
A function that returns the result or the default value.
A function to wrap for safe execution.
Default return value when an error occurs.
Logical. Hide errors from console if TRUE.
safe_log <- s_possibly(log, otherwise = NA) safe_log(10) # Returns 2.30 safe_log("a") # Returns NA
Run the code above in your browser using DataLab