What is the colors() function in R?
Overview
The colors() function in R is used to return all the built-in color names in R.
Syntax
colors(distinct = FALSE)colours(distinct = FALSE)
Syntax for the "colors()" function
Note: Thecolors()function can also be interchanged with thecolours()function.
Parameters
The colors() function takes a single parameter value, distinct, which takes a Boolean value of either TRUE or FALSE.
Return value
The colors() function returns a character vector that contains all the built-in color names in R.
Code examples
# Getting all the built-in colors in Rcolors(distinct=FALSE)
# Getting all the built-in distinc colors in Rcolors(distinct=TRUE)
Code explanation
The distinct parameter indicates whether the colors returned are distinct or not, for example, "snow" and "snow1" are effectively the same point in the FALSE.