Learn R Programming

assertive.data (version 0.0-3)

assert_all_are_ip_addresses: Does the character vector contain IP addresses?

Description

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

Usage

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

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

is_ip_address(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

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

Examples

Run this code
# NOT RUN {
x <- c(
  localhost     = "localhost", 
  valid_address = "255.0.255.0", 
  out_of_range  = "1.2.3.256",
  five_blocks   = "1.2.3.4.5",
  non_numeric   = "1.2.3.Z",
  missing_block = "1.2.3.NA",
  missing       = NA
)
is_ip_address(x)
assert_any_are_ip_addresses(x)
#These examples should fail.
assertive.base::dont_stop(assert_all_are_ip_addresses(x))
# }

Run the code above in your browser using DataLab