Learn R Programming

assertive (version 0.1-7)

assert_all_are_hex_colours: Does the character vector contain hex colours?

Description

Checks that the input contains hexadecimal colours.

Usage

assert_all_are_hex_colours(x)

  assert_any_are_hex_colours(x)

  is_hex_colour(x)

Arguments

x
Input to check.

Value

  • A logical vector that is TRUE when the input contains hex colours.

Examples

Run this code
x <- c(
  "#0123456", "#789abc", "#defDEF", #ok
  "012345",                         #no hash
  "#g12345",                        #bad letter
  "#01 23 45",                      #contains spaces
  "#12345", "#1234567"              #wrong length
)
is_hex_colour(x)
assert_any_are_hex_colours(x)
#These examples should fail.
assert_all_are_hex_colours(x)

Run the code above in your browser using DataLab