schochastics / dialrs

https://schochastics.github.io/dialrs/
Apache License 2.0
7 stars 1 forks source link

dialrs

R-CMD-check CRAN
status

dialrs is an experimental R package to parse phone numbers using the Rust crate phonenumber.

Installation

You can install the development version of dialrs like so:

remotes::install_github("schochastics/dialrs")
pak::pak("schochastics/dialrs")

Example

library(dialrs)
numbers <- c("+1 202-555-0173", "+33 122 334 455", "+1 1 800 FLOWERS")
phone_is_valid(numbers)
#> [1]  TRUE  TRUE FALSE
phone_type(numbers)
#> [1] "fixed_line_or_mobile" "fixed_line"           "unknown"
phone_country_code(numbers)
#> [1]  1 33  1
phone_parse(numbers, format = "International")
#> [1] "+1 202-555-0173"   "+33 1 22 33 44 55" "+1 18003569377"
phone_parse(numbers, format = "National")
#> [1] "(202) 555-0173" "01 22 33 44 55" "18003569377"
phone_parse(numbers, format = "RFC3966")
#> [1] "tel:+1-202-555-0173"   "tel:+33-1-22-33-44-55" "tel:+1-18003569377"
phone_parse(numbers, format = "E.164")
#> [1] "+12025550173"  "+33122334455"  "+118003569377"

Note

There is already an R package for that, called dialr, which wraps Google’s libphonenumber Java library.