assert_all_are_us_social_security_numbers

0th

Percentile

Is the string a valid US SSN?

Checks that the input contains US Social Security Number.

Usage
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)

Arguments
x

Input to check.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

Value

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.

Note

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.

Aliases
  • assert_all_are_us_social_security_numbers
  • assert_any_are_us_social_security_numbers
  • is_us_social_security_number
Examples
# NOT RUN {
ssns <- c("123-45-6789", "666-45-6789", "123-00-6789")
is_us_social_security_number(ssns)
# }
Documentation reproduced from package assertive.data.us, version 0.0-2, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.