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.
get_region(x)
get_supported_regions()
get_region_for_calling_code(x)
get_regions_for_calling_code(x)
A phone vector, or a vector of calling codes.
A character vector of country codes.
get_regions_for_calling_code()
returns a list of character vectors for
each provided calling code.
get_region()
: PhoneNumberUtil.getRegionCodeForNumber()
get_supported_regions()
: PhoneNumberUtil.getSupportedRegions()
get_region_for_calling_code()
:
PhoneNumberUtil.getRegionCodeForCountryCode()
get_regions_for_calling_code()
:
PhoneNumberUtil.getRegionCodesForCountryCode()
Other phone functions:
dialr-example
,
dialr-match
,
dialr-phone
,
dialr-type
,
dialr-valid
,
dialr
# Get regions for a phone vector
x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
get_region(x)
#> [1] NA NA "AU" "AU" "AU" "US"
# All supported region codes
get_supported_regions()
#> [1] "PR" "PS" "PT" "PW" "PY" "QA" "AC" "AD" "AE" "AF" "AG" "AI" "AL" "AM" "AO"
#> [16] "AR" "AS" "AT" "RE" "AU" "AW" "AX" "AZ" "RO" "BA" "BB" "RS" "BD" "RU" "BE"
#> [31] "BF" "RW" "BG" "BH" "BI" "BJ" "BL" "BM" "BN" "BO" "SA" "BQ" "SB" "BR" "SC"
#> [46] "BS" "SD" "SE" "BT" "SG" "BW" "SH" "SI" "SJ" "BY" "SK" "BZ" "SL" "SM" "SN"
#> [61] "SO" "CA" "SR" "CC" "SS" "ST" "CD" "CF" "SV" "CG" "SX" "CH" "CI" "SY" "SZ"
#> [76] "CK" "CL" "CM" "CN" "CO" "TA" "TC" "CR" "TD" "CU" "TG" "CV" "TH" "CW" "CX"
#> [91] "CY" "TJ" "TK" "CZ" "TL" "TM" "TN" "TO" "TR" "TT" "DE" "TV" "TW" "DJ" "TZ"
#> [106] "DK" "DM" "DO" "UA" "UG" "DZ" "US" "EC" "EE" "EG" "EH" "UY" "UZ" "VA" "VC"
#> [121] "ER" "ES" "VE" "ET" "VG" "VI" "VN" "VU" "FI" "FJ" "FK" "FM" "FO" "FR" "WF"
#> [136] "GA" "GB" "WS" "GD" "GE" "GF" "GG" "GH" "GI" "GL" "GM" "GN" "GP" "GQ" "GR"
#> [151] "GT" "GU" "GW" "GY" "XK" "HK" "HN" "HR" "YE" "HT" "HU" "ID" "YT" "IE" "IL"
#> [166] "IM" "IN" "IO" "ZA" "IQ" "IR" "IS" "IT" "ZM" "JE" "ZW" "JM" "JO" "JP" "KE"
#> [181] "KG" "KH" "KI" "KM" "KN" "KP" "KR" "KW" "KY" "KZ" "LA" "LB" "LC" "LI" "LK"
#> [196] "LR" "LS" "LT" "LU" "LV" "LY" "MA" "MC" "MD" "ME" "MF" "MG" "MH" "MK" "ML"
#> [211] "MM" "MN" "MO" "MP" "MQ" "MR" "MS" "MT" "MU" "MV" "MW" "MX" "MY" "MZ" "NA"
#> [226] "NC" "NE" "NF" "NG" "NI" "NL" "NO" "NP" "NR" "NU" "NZ" "OM" "PA" "PE" "PF"
#> [241] "PG" "PH" "PK" "PL" "PM"
# Primary region for a calling code
get_region_for_calling_code(c(1, 61, 84))
#> [1] "US" "AU" "VN"
# All regions for a calling code
get_regions_for_calling_code(c(1, 61, 84))
#> [[1]]
#> [1] "US" "AG" "AI" "AS" "BB" "BM" "BS" "CA" "DM" "DO" "GD" "GU" "JM" "KN" "KY"
#> [16] "LC" "MP" "MS" "PR" "SX" "TC" "TT" "VC" "VG" "VI"
#>
#> [[2]]
#> [1] "AU" "CC" "CX"
#>
#> [[3]]
#> [1] "VN"
#>