assertive.data (version 0.0-3)

assert_all_are_email_addresses: Does the character vector contain email addresses?

Description

Checks that the input contains email addresses. (It does not check the the address exists, merely that the string is in a suitable format.)

Usage

assert_all_are_email_addresses(x, method = c("simple", "rfc5322"),
  na_ignore = FALSE, severity = getOption("assertive.severity",
  "stop"))

assert_any_are_email_addresses(x, method = c("simple", "rfc5322"), na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

is_email_address(x, method = c("simple", "rfc5322"))

Arguments

x

Input to check.

method

Name of method to check for validity. See notes below.

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

A logical vector that is TRUE when the input contains valid email addresses.

References

http://www.regular-expressions.info/email.html contains the regexes used by this function and a good discussion of the pros and cons of each.

Examples

Run this code
# NOT RUN {
addresses <- c(
  ok       = "a@b.com", 
  no_at    = "a_at_b.com", 
  no_dot   = "a@bcom", 
  long_tld = "a@b.comma", 
  punct    = "a!$&@b.com", 
  missing  = NA
)
is_email_address(addresses)
is_email_address(addresses, method = "rfc5322")
# }

Run the code above in your browser using DataLab