Skip to contents
  • phone_type() returns the number type ("fixed_line", "mobile", "fixed_line_or_mobile", "toll_free", "premium_rate", "shared_cost", "voip", "personal_number", "pager", "uan", "voicemail", or "unknown" when parsed but not valid under the numbering plan).

  • phone_region() returns the two-letter CLDR region code (or "001" for non-geographic calling codes such as +800).

Usage

phone_type(x, region = NULL)

phone_region(x, region = NULL)

Arguments

x

A character vector of phone numbers (or an existing dialtone_phone data frame returned by phone_parse()).

region

A single two-letter CLDR region code (such as "US", "GB" or "IN") giving the default country for numbers written without a leading +, or NULL when numbers are in international format.

Value

A character vector the same length as x, with NA_character_ where x is NA or cannot be parsed.

Examples

phone_type(c("+44 20 7946 0192", "+44 7700 900077", "+1 800-234-5678", "not a number"))
#> [1] "fixed_line" "unknown"    "toll_free"  NA          
phone_region(c("+1 650-253-0000", "+1 416-555-0199", "+44 20 7946 0192", "+800 1234 5678"))
#> [1] "US"  "CA"  "GB"  "001"