get_geocode: Phone number geographical information

Description Usage Arguments Details Value libphonenumber reference Examples

View source: R/geocoder.R

Description

Returns a text description for each phone number, in the language provided in locale.

Usage

1
get_geocode(x, home = NULL, strict = FALSE, locale = getOption("dialr.locale"))

Arguments

x

A phone vector.

home

ISO country code for home region. See Details.

strict

Should invalid phone numbers be removed? If TRUE, invalid phone numbers are replaced with NA.

locale

The Java locale used to retrieve localised results. The default is set in option dialr.locale.

Details

The description might consist of the name of the country where the phone number is from, or the name of the geographical area the phone number is from if more detailed information is available.

If a phone number is from the region specified in home, only a lower-level description will be returned, if one exists. Otherwise, the phone number's region will be returned, with optionally some more detailed information.

For example, for a user from the region "US" (United States), we would show "Mountain View, CA" for a particular number, omitting the United States from the description. For a user from the United Kingdom (region "GB"), for the same number we may show "Mountain View, CA, United States" or even just "United States".

Value

A text description for each phone number for the given locale, or "" if the number is invalid or could belong to multiple countries.

libphonenumber reference

get_geocode(): PhoneNumberOfflineGeocoder.getDescriptionForValidNumber().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
get_geocode(x)
get_geocode(x, strict = TRUE)

# Specify a home country
get_geocode(x, home = "AU")
get_geocode(x, home = "US")

# Specify a language
get_geocode(x, home = "DE", locale = "de")

Example output

OpenJDK 64-Bit Server VM warning: Can't detect primordial thread stack location - find_vma failed
[1] NA           ""           ""           ""           "Australia" 
[6] "New Jersey"
[1] NA           NA           ""           ""           "Australia" 
[6] "New Jersey"
[1] NA              ""              ""              ""             
[5] "Australia"     "United States"
[1] NA           ""           "Australia"  "Australia"  "Australia" 
[6] "New Jersey"
[1] NA                   ""                   "Australien"        
[4] "Australien"         "Australien"         "Vereinigte Staaten"

dialr documentation built on May 24, 2021, 5:07 p.m.