isColor: Check whether color specifications exists.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/util.R

Description

Function to check whether all specified colors are actual colors.

Usage

1
isColor(x, return.colors = FALSE)

Arguments

x

Vector of any of the three kinds of R color specifications, i.e., either a color name (as listed by palettecolors()), a hexadecimal string of the form '#rrggbb' or '#rrggbbaa' (see rgb), or a positive integer i meaning palette()[i].

return.colors

Logical: logical values (FALSE, default) or returning colors (TRUE)

Value

Logical value (or colors)

Author(s)

Jacolien van Rij

See Also

Other Utility functions: findAbsMin(), find_n_neighbors(), firstLetterCap(), getArrowPos(), getDec(), getRange(), getRatioCoords(), get_palette(), group_sort(), inch2coords(), list2str(), move_n_point(), orderBoxplot(), se(), sortGroups()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# correct color definitions:
isColor(c('#FF0000FF', '#00FF00FF', '#0000FFFF'))
isColor(c('red', 'steelblue', 'green3'))
isColor(c(1,7,28))
# mixtures are possible too:
isColor(c('#FF0000FF', 'red', 1, '#FF0000', rgb(.1,0,0)))

# return colors:
# note that 28 is converted to 4...
isColor(c(1,7,28), return.colors=TRUE) 
isColor(c('#FF0000CC', 'red', 1, '#FF0000'), return.colors=TRUE)

# 4 incorrect colors, 1 correct:
test <- c('#FH0000', 3, '#FF00991', 'lavendel', '#AABBCCFFF')
isColor(test)
isColor(test, return.colors=TRUE)

plotfunctions documentation built on April 28, 2020, 5:10 p.m.