Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

is.cnumeric

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

str2str

Convert R Objects from One Structure to Another

v0.1.1
GPL (>= 2)
Authors
David Disabato [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.