is.cnumeric {str2str} | R Documentation |
Test for Character Numbers
Description
is.cnumeric
returns whether an object is a character vector with all
number strings.
Usage
is.cnumeric(x, warn = FALSE)
Arguments
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'). |
Details
is.cnumeric
is useful for ensuring that converting a character vector to
a numeric vector is safe (i.e., won't introduce NAs).
Value
logical vector with length 1 specifying whether 'x' is a character vector with all number strings.
Examples
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
[Package str2str version 1.0.0 Index]