tonum: Convert to number.

Description Usage Arguments Value Examples

Description

My flexible number conversion function.

Usage

1
2
3
4
tonum(x, already.clean.vector = FALSE, na.vals = bc::nastrings,
  na.zero = FALSE, do.remove.chars = FALSE,
  do.na = c("return-unchanged", "warning", "stop", "return-na"),
  verbose = TRUE)

Arguments

x

Vector to be covnerted to numeric.

already.clean.vector

Sometimes in multi-step data operations clean.vector will have already been called.#'

na.vals

Values to consider NA.

na.zero

Set NA values to 0.

do.remove.chars

Remove characters that aren't numeric or numeric-related to aggressively extract numbers from strings.

do.na

What to do if new NA values are crated during the conversion.

verbose

Print messages (via cat) about what the function is doing.

Value

Result vector.

Examples

1
2
tonum( c( '1st', '2nd', '3rd' ) )
tonum( c( '1.05', '30%', '-30%', '-45' ) )

superchordate/bc documentation built on June 20, 2019, 4:05 p.m.