std_num() converts all base classes, as well as int64, factor, Date,
and POSIXt vectors to the simplest numeric form possible.
Arguments
- x
A vector to convert to numeric
- na
Regex patterns to consider
NA. Passed tostringr::str_detect(). Can be a vector of patterns.- std_chr
Whether to standardize a
characterorfactorbefore conversion- warn
Whether to warn when strings cannot be converted; passed to
chr_to_num()- ...
Arguments passed on to
chr_to_numstdWhether to standardize the vector before cleaning and converting
convertWhether to actually convert to
numericreplaceA
data.frameof regular expressions and strings to replace them; regular expression should be in a column namedpattern, and replacements should be in a column namedreplacement. Each row is passed tostringr::str_replace().per_actionHow to treat %/percent/per million/etc labels.
dropsimply removes the labels,dividedivides the value by the appropriate denominator, andignoredoes nothing.multiple_decimalsHow to handle multiple decimals within a number
donor_hostWhich value to use when values for both a donor and a host are given
Details
character vectors are standardized using std_chr() by default, then
converted. factors are treated as character vectors, rather than using
the underlying integer representation. double and int64 vectors will be
converted to integer if this does not cause overflow or loss of precision.
Date is converted to integer, and POSIXt is converted to integer if
the range allows, otherwise double.