AsNumeric: AsNumeric

Description Usage Arguments Author(s) Examples

View source: R/utils.R

Description

By default, the function converts the input to numeric if it can be coerced. Otherwise, the original input is returned. If all elements in the vector can be coerced to numeric, the resulting vector will be numeric.

Usage

1
AsNumeric(x, return_NA = FALSE)

Arguments

x

Vector.

return_NA

Logical. If return_NA = TRUE, returns NA when x cannot be coerced. If return_NA = FALSE, returns the original item when x cannot be coerced.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

1
2
3
4
5
x <- c("1", "2", "3")
AsNumeric(x)
x <- c("1", "2", "3", "a")
AsNumeric(x, return_NA = FALSE)
AsNumeric(x, return_NA = TRUE)

jeksterslab/ramR documentation built on March 14, 2021, 9:38 a.m.