Learn R Programming

assertive.data.uk (version 0.0-2)

assert_all_are_uk_telephone_numbers: Is the string a valid UK telephone number?

Description

Checks that the input contains UK telephone numbers.

Usage

assert_all_are_uk_telephone_numbers(x, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_uk_telephone_numbers(x, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

is_uk_telephone_number(x)

Arguments

x

Input to check.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

Value

is_uk_telephone_number returns TRUE if the input string contains a valid UK telephone number. The assert_* function returns nothing but throws an error when the is_* function returns FALSE.

References

The regex is adapted from one on the now defunct aa-asterisk.org.uk site with some additional consultation from https://en.wikipedia.org/wiki/List_of_United_Kingdom_dialling_codes

Examples

Run this code
# NOT RUN {
phone_nos <- c("+44 207 219 3475", "08457 90 90 90")
is_uk_telephone_number(phone_nos)
assert_all_are_uk_telephone_numbers(phone_nos)
# }

Run the code above in your browser using DataLab