dialr-region: Phone number region

dialr-regionR Documentation

Phone number region

Description

In libphonenumber a phone number region is represented by a 2 digit ISO country code. get_region(x) returns the 2-digit ISO country code for each element of a phone vector.

Use get_supported_regions() to see a full list of supported regions.

Region can also be retrieved from an international calling code. get_region_for_calling_code(x) returns the main region for each provided calling code. Since multiple regions can share a single calling code, get_regions_for_calling_code(x) returns a list of character vectors of regions for each.

Usage

get_region(x)

get_supported_regions()

get_region_for_calling_code(x)

get_regions_for_calling_code(x)

Arguments

x

A phone vector, or a vector of calling codes.

Value

A character vector of country codes.

get_regions_for_calling_code() returns a list of character vectors for each provided calling code.

libphonenumber reference

get_region(): PhoneNumberUtil.getRegionCodeForNumber()

get_supported_regions(): PhoneNumberUtil.getSupportedRegions()

get_region_for_calling_code(): PhoneNumberUtil.getRegionCodeForCountryCode()

get_regions_for_calling_code(): PhoneNumberUtil.getRegionCodesForCountryCode()

See Also

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

Examples

  # Get regions for a phone vector
  x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
  get_region(x)

  # All supported region codes
  get_supported_regions()
  
  # Primary region for a calling code
  get_region_for_calling_code(c(1, 61, 84))
  
  # All regions for a calling code
  get_regions_for_calling_code(c(1, 61, 84))
  

dialr documentation built on Oct. 17, 2023, 1:11 a.m.