knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) # load dplyr here to avoid mask warnings library(dplyr, warn.conflicts = FALSE)
dialr is an R interface to Google's libphonenumber library. It uses the java implementation of libphonenumber via rJava for all phone number processing.
For a full rundown of libphonenumber see their GitHub and javadocs.
You can install the released version of dialr from CRAN with:
install.packages("dialr")
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("socialresearchcentre/dialr")
library(dialr) # Parse a character phone number vector x <- c(0, 0123, "0404 753 123", "61410123817", "+12015550123") x <- phone(x, "AU") is_parsed(x) # Was the phone number successfully parsed? is_valid(x) # Is the phone number valid? is_possible(x) # Is the phone number possible? get_region(x) # What region (ISO country code) is the phone number from? get_type(x) # Is the phone number a fixed line, mobile etc. format(x) format(x, home = "AU") # Use with dplyr library(dplyr) y <- tibble(id = 1:4, phone1 = c(0, 0123, "0404 753 123", "61410123817"), phone2 = c("03 9388 1234", 1234, "+12015550123", 0), country = c("AU", "AU", "AU", "AU")) y %>% mutate_at(vars(matches("^phone")), ~phone(., country)) %>% mutate_at(vars(matches("^phone")), list(valid = is_valid, region = get_region, type = get_type, clean = format))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.