Check if All Elements in Character Vector are Numeric

DESCRIPTION:

Tests, without issuing warnings, whether all elements of a character vector are legal numeric values, or optionally converts the vector to a numeric vector.

USAGE:

all.is.numeric(x, what = c("test", "vector"))

ARGUMENTS:

x
a character vector
what
specify what="vector" to return a numeric vector if it passes the test, or the original character vector otherwise

VALUE:

a logical value if what="test" or a vector otherwise

AUTHOR(S):

Frank Harrell

SEE ALSO:

EXAMPLES:

all.is.numeric(c('1','1.2','3'))
all.is.numeric(c('1','1.2','3a'))
all.is.numeric(c('1','1.2','3'),'vector')
all.is.numeric(c('1','1.2','3a'),'vector')