force_num | R Documentation |
Coerces a vector into a numeric vector and automatically silences NAs introduced by coercion
warning. Useful for cases where non-numbers are known to exist in vector and their coercion to NA is expected / unremarkable. Essentially just a way of forcing this coercion more succinctly than wrapping as.numeric
in suppressWarnings
.
force_num(x = NULL)
x |
(non-numeric) vector containing elements to be coerced into class numeric |
(numeric) vector of numeric values
# Coerce a character vector to numeric without throwing a warning
force_num(x = c(2, "A", 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.