Skip to contents

This function tries to evaluate a function, and if the function throws an error, it returns FALSE. Otherwise, it returns TRUE.

Usage

s_try(.fn)

Arguments

.fn

A function call.

Value

A logical value.

Examples

s_try(mean(1:10))
#> [1] TRUE

# This gives a warning, but it is still working, so s_try() returns TRUE
s_try(mean(letters[1:10]))
#> Warning: argument is not numeric or logical: returning NA
#> [1] TRUE

# This throws an error, so s_try() returns FALSE
s_try(means(1:10))
#> [1] FALSE