dialr-example: Get an example phone number

dialr-exampleR Documentation

Get an example phone number

Description

Produces example phone numbers for the given region, type and valid combinations. Input vectors are recycled as necessary if a vector of length 1 is provided.

Usage

get_example(region, type = NULL, valid = TRUE)

Arguments

region

A character vector of ISO country codes.

type

A character vector of phone number types for each region. If NULL (default), returns an example "FIXED_LINE" number. Returns an empty phone number if type is not valid for the provided region.

valid

A logical vector. For each FALSE entry, get_example returns an example invalid number, and type is ignored.

Value

A phone vector.

libphonenumber reference

get_example(): PhoneNumberUtil.getExampleNumberForType(); PhoneNumberUtil.getExampleNumber() if type is NULL or NA; PhoneNumberUtil.getInvalidExampleNumber() if valid is FALSE.

See Also

get_supported_regions() for valid region codes, get_types_for_region() to get valid phone types for a region.

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

Examples

# Get a basic example number
get_example("AU")

# Get an example mobile number
get_example("AU", type = "MOBILE")

# Example phone number for an invalid type
get_example("AU", type = "VOICEMAIL")

# Get an example invalid number
get_example("AU", valid = FALSE)

# Get a combination of the previous examples
get_example(c("AU", "AU",     "AU",        "AU" ),
            c(NA,   "MOBILE", "VOICEMAIL", NA   ),
            c(TRUE, TRUE,     TRUE,        FALSE))

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