normal_phone: Normalize phone number
Description
Take US phone numbers in any number of formats and try to convert them to a
standard format.
Usage
normal_phone(
number,
format = "(%a) %e-%l",
na_bad = FALSE,
convert = FALSE,
rm_ext = FALSE
)
Value
A normalized telephone number.
Arguments
- number
A vector of phone number in any format.
- format
The desired output format, with %a
representing the 3-digit
area code, %e
representing the 3-digit exchange, and %l
representing the 4-digit line number. The punctuation between each part
of the format is used in the normalized number (e.g., "(%a) %e-%l"
or
"%a-%e-%l"
).
- na_bad
logical; Should invalid numbers be replaced with NA
.
- convert
logical; Should keypad_convert()
be invoked to replace
numbers with their keypad equivalent.
- rm_ext
logical; Should extensions be removed from the end of a number.
Examples
Run this codenormal_phone(number = c("916-225-5887"))
Run the code above in your browser using DataLab