View source: R/str2str_functions.R
is.cnumeric | R Documentation |
is.cnumeric
returns whether an object is a character vector with all
number strings.
is.cnumeric(x, warn = FALSE)
x |
object whose structure is desired to be tested. |
warn |
logical vector with length 1 specifying whether warnings should be printed due to coercing a character vector that is not all number strings (i.e., one reason the return object could be 'FALSE'). |
is.cnumeric
is useful for ensuring that converting a character vector to
a numeric vector is safe (i.e., won't introduce NAs).
logical vector with length 1 specifying whether 'x' is a character vector with all number strings.
is.cnumeric(x = c("1","2","3")) # returns TRUE
is.cnumeric(x = c("1","number","3")) # returns FALSE
is.cnumeric(x = c("1","number","3"), warn = TRUE) # includes the warning
is.cnumeric(x = c(1,2,3)) # returns false because not a character vector
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.