| assert_all_are_us_social_security_numbers {assertive.data.us} | R Documentation |
Checks that the input contains US Social Security Number.
assert_all_are_us_social_security_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_any_are_us_social_security_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
is_us_social_security_number(x)
x |
Input to check. |
na_ignore |
A logical value. If |
severity |
How severe should the consequences of the assertion be?
Either |
is_us_social_security_number returns TRUE if the input
string contains a valid US Social Security Number. The assert_* functions
return nothing but throw an error when the is_* function returns
FALSE.
A valid SSN is considered to be 3 digits, then 2 digits then 4 digits possibly separated by a hyphen or space. The first block cannot be 666 or a begin with a nine, and no block can contain all zeroes. The function doesn't guarantee that the SSN actually exists.
ssns <- c("123-45-6789", "666-45-6789", "123-00-6789")
is_us_social_security_number(ssns)