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.

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")
#> # Parsed phone numbers: 1 total, 1 successfully parsed
#> [1] +61212345678

# Get an example mobile number
get_example("AU", type = "MOBILE")
#> # Parsed phone numbers: 1 total, 1 successfully parsed
#> [1] +61412345678

# Example phone number for an invalid type
get_example("AU", type = "VOICEMAIL")
#> # Parsed phone numbers: 1 total, 0 successfully parsed
#> [1] <NA>

# Get an example invalid number
get_example("AU", valid = FALSE)
#> # Parsed phone numbers: 1 total, 1 successfully parsed
#> [1] +6121234567

# Get a combination of the previous examples
get_example(c("AU", "AU",     "AU",        "AU" ),
            c(NA,   "MOBILE", "VOICEMAIL", NA   ),
            c(TRUE, TRUE,     TRUE,        FALSE))
#> # Parsed phone numbers: 4 total, 3 successfully parsed
#> [1] +61212345678 +61412345678 <NA>         +6121234567