get_carrier: Phone number carrier information

Description Usage Arguments Details Value libphonenumber reference Examples

View source: R/carrier.R

Description

Returns a carrier name for each phone number, in the language provided in locale.

Usage

1
2
3
4
5
6
get_carrier(
  x,
  strict = FALSE,
  safe = FALSE,
  locale = getOption("dialr.locale")
)

Arguments

x

A phone vector.

strict

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

safe

If TRUE, gets the name of the carrier for a given phone number only when it is 'safe' to display to users. A carrier name is considered safe if the number is valid and for a region that doesn't support mobile number portability. All other phone numbers return "".

locale

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

Details

The carrier name is the one the number was originally allocated to, however if the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found "" is returned.

Value

A carrier name for each phone number for the given locale, or "" if the number is invalid.

libphonenumber reference

get_geocode(): PhoneNumberToCarrierMapper.getNameForValidNumber() by default, or PhoneNumberToCarrierMapper.getSafeDisplayName() if safe = TRUE.

Examples

1
2
3
4
x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
get_carrier(x)
get_carrier(x, strict = TRUE)
get_carrier(x, safe = TRUE)

Example output

[1] NA      ""      "Optus" "Optus" ""      ""     
[1] NA      NA      "Optus" "Optus" ""      ""     
[1] NA NA "" "" "" ""

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