R/try_as_numeric.R

Defines functions try_as_numeric

# Try to apply as.numeric, but if any warnings or errors occur, just use the
# original column values
try_as_numeric <- function(x) {
    tryCatch(
        {
            # Code to be executed initially
            as.numeric(x)
        },
        error=function(cond) {
            # Code for handling errors
            x
        },
        warning=function(cond) {
            # Code for handling warnings
            x
        }
    )
}

Try the PhotoGEA package in your browser

Any scripts or data that you put into this service are public.

PhotoGEA documentation built on April 11, 2025, 5:48 p.m.