Learn R Programming

assertive (version 0.2-1)

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)

assert_any_are_ip_addresses(x)

is_ip_address(x)

Arguments

x
Input to check.

Value

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

Examples

Run this code
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.
dont_stop(assert_all_are_ip_addresses(x))

Run the code above in your browser using DataLab