assert_all_are_hex_colors

0th

Percentile

Does the character vector contain hex colors?

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.

Note

A string is considered to represent a hexadecimal colour when contains a hash followed by six hex values. That is, digits or the letters from a to f (case insensitive).

Aliases
• assert_all_are_hex_colors
• assert_any_are_hex_colors
• assert_all_are_hex_colours
• assert_any_are_hex_colours
• is_hex_color
• is_hex_colour
Examples
# NOT RUN {
x <- c(
"#012345", "#789abc", "#defDEF",  #ok
"012345",                         #no hash
"#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))
# }

Documentation reproduced from package assertive.data, version 0.0-3, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.