charnum {easyr} | R Documentation |
Check for Number Formatted as Character.
Description
Checks a vector or value to see if it is a number formatted as a character. Useful for checking columns formatted with $ or commas, etc. Author: Bryce Chamberlain. Tech review: Dominic Dillingham.
Usage
charnum(x, na_strings = easyr::nastrings, run_unique = TRUE, check_date = TRUE)
Arguments
x |
Vector to check. |
na_strings |
Strings to consider NA. |
run_unique |
Convert to unique variables before checking. In some cases, this can make it take longer than necessary. In most, it will make it faster. |
check_date |
Check for a date, in which case it isn't a number. If you have already checked a date and know it isn't, set this to FALSE to run faster. |
Value
True/false value indicating if the vector is a number formatted as a character. Helpful for checking before calling easyr:tonum().
Examples
charnum( c(
'123', '$50.02', '30%', '(300.01)', '-10', '1 230.4', NA, '-', '', "3.7999999999999999E-2"
))
charnum( c( '123', 'abc', '30%', NA) )
# returns FALSE since this can be converted to a date:
charnum( c( '20180101' ))
[Package easyr version 0.5-11 Index]