try_na: Wrapper for "try" function

View source: R/try_na.R

try_naR Documentation

Wrapper for "try" function

Description

try_na silly wrapper for try function that returns an NA if an error is found. TO BE DEPRECATED IN FUTURE VERSIONS.

Usage

try_na(expr, silent = TRUE, outFile)

Arguments

expr

An R expression to try.

silent

Logical to control whether the report of error messages is suppressed. Default is TRUE.

outFile

A connection, or a character string naming the file to print to (via message2(*, file = outFile)); used only if silent is false, as by default.

Details

This is a silly wrapper on try that returns an 'NA' if any error occurs during the evaluation of a expression. See try for details.

Value

Returns an 'NA' if any error occurs during the evaluation of a expression. If not, it will return the result of the evaluation.

Author(s)

Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)

References

Araya-Salas, M., & Smith-Vidaurre, G. (2017). warbleR: An R package to streamline analysis of animal acoustic signals. Methods in Ecology and Evolution, 8(2), 184-191.

Examples

{
# try a function that does not exists to produce an error
try_na(crazy78(12))

# try a real function (no error)
try_na(mean(1:5))
}


maRce10/warbleR documentation built on March 28, 2024, 12:05 p.m.