assertive.data (version 0.0-3)

assert_all_are_hex_colors: Does the character vector contain hex colors?

Description

Checks that the input contains hexadecimal colors.

Usage

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

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

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

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

is_hex_color(x)

is_hex_colour(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 hex colours.

Examples

Run this code
# NOT RUN {
x <- c(
  "#012345", "#789abc", "#defDEF",  #ok
  "012345",                         #no hash
  "#g12345",                        #bad letter
  "#01 23 45",                      #contains spaces
  "#12345", "#1234567"              #wrong length
)
is_hex_color(x)
assert_any_are_hex_colors(x)
#These examples should fail.
assertive.base::dont_stop(assert_all_are_hex_colors(x))
# }

Run the code above in your browser using DataLab