dialr-match {dialr}R Documentation

Phone number equality checks

Description

Check if two vectors contain matching phone numbers. See Details section for a full list of match types. is_match() with default arguments is used to implement == and != for phone vectors.

is_match() accepts phone or atomic vectors. Atomic vectors are converted to character for comparison. Note that although they can contain formatting character vectors are not parsed with a default region, so they will only ever be an "EXACT_MATCH" if a country calling code is specified with + at the start. See Examples.

Usage

is_match(e1, e2, detailed = FALSE, strict = TRUE, not_number_na = TRUE)

Arguments

e1

A phone or character vector.

e2

A phone or character vector.

detailed

If FALSE, is_match() returns a logical vector. If TRUE, it returns a character vector with the match type. See Details section for possible return values.

strict

If TRUE, only "EXACT_MATCH" is treated as a match. If FALSE, "EXACT_MATCH", "NSN_MATCH" and "SHORT_NSN_MATCH" are all considered a match. Ignored if detailed = TRUE.

not_number_na

If TRUE, "NOT_A_NUMBER" is converted to NA.

Details

Possible return values for is_match(x, detailed = TRUE):

For example, the numbers ⁠+1 345 657 1234⁠ and ⁠657 1234⁠ are a "SHORT_NSN_MATCH". The numbers ⁠+1 345 657 1234⁠ and ⁠345 657⁠ are a "NO_MATCH".

Value

A logical or character vector.

libphonenumber reference

is_match(): PhoneNumberUtil.isNumberMatch()

See Also

Other phone functions: dialr-example, dialr-phone, dialr-region, dialr-type, dialr-valid, dialr

Examples

is_match(phone("0412 345 678", "AU"), phone("+61412345678", "AU"))

phone("0412 345 678", "AU") == phone("+61412345678", "AU")
phone("0412 345 678", "AU") != phone("+61412345678", "AU")

# character vectors are only fully specified with a country calling code
is_match("0412345678", "0412345678", detailed = TRUE)
is_match("+61412345678", "+61412345678", detailed = TRUE)

is_match(phone("0412345678", "AU"), "0412345678", detailed = TRUE)
is_match(phone("+61412345678", "AU"), "+61412345678", detailed = TRUE)

[Package dialr version 0.4.2 Index]