isNumeral: Can Character Vector Be Coerced To Numeric?

View source: R/isNumeral.R

isNumeralR Documentation

Can Character Vector Be Coerced To Numeric?

Description

Determines whether each element of a character vector can be coerced to numeric.

Usage

isNumeral(c)

is.numeral(c)

Arguments

c

A vector of strings.

Details

Checks element-wise as to whether each item in a vector of strings can be coerced to numeric.

Basics cribbed from http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#R.

is.numeral() is deprecated.

Value

A vector of logicals, NA where is.na(c).

Author(s)

David Braze davebraze@gmail.com

Examples

x <- c('a', 'IX', 'twelve', '0001', '2', '3e1', '-4', '5.5', 'Inf', NA)
data.frame(x,
           isNumeral(x),
           as.numeric(x))

davebraze/FDButils documentation built on Feb. 24, 2023, 12:14 a.m.