is_us_social_security_number: Is the string a valid US SSN?

Description Usage Arguments Value Note Examples

View source: R/is-data-us.R

Description

Checks that the input contains US Social Security Number.

Usage

1
2
3
4
5
6
7
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.

Examples

1
2
ssns <- c("123-45-6789", "666-45-6789", "123-00-6789")
is_us_social_security_number(ssns)

assertive.data.us documentation built on May 2, 2019, 12:22 p.m.