** gray() or grey()** function in R Language is used to create a vector of colors from a vector of gray levels.

Syntax:

gray(level)

or

grey(level)

Parameters:

level:a vector of desired gray levels between 0 and 1; zero indicates “black” and one indicates “white”.

**Example 1:**

`# R program to illustrate ` `# gray function ` ` ` `# Calling the gray() function ` `gray(` `0` `) ` `gray(` `1` `) ` |

*chevron_right*

*filter_none*

**Output:**

[1] "#000000" [1] "#FFFFFF"

**Example 2:**

`# R program to illustrate ` `# gray function ` ` ` `# Calling the gray() function ` `gray(` `0` `:` `9` `/` `9` `) ` |

*chevron_right*

*filter_none*

**Output:**

[1] "#000000" "#1C1C1C" "#393939" "#555555" "#717171" "#8E8E8E" "#AAAAAA" [8] "#C6C6C6" "#E3E3E3" "#FFFFFF"

## Recommended Posts:

- Create a Range of Colors between the Specified Colors in R Programming - colorRampPalette() Function
- Create a Range of Contiguous Colors Clustered around the Red Spectrum of the RGB Scale in R Programming - heat.colors() Function
- Get a List of all the 657 colors in R Programming - colors() Function
- Create a Vector of Colors with specified Hue, Chroma and Luminance in R Programming - hcl() Function
- Create a Vector of Colors with specified Hue, Saturation and Value in R Programming - hsv() Function
- Get or Set Levels of a Factor in R Programming - levels() Function
- Generate a Vector of specified length with each element as a unique color on RGB scale in R Language - topo.colors() Function
- Generate a Vector of specified length with each element as a unique color on RB scale in RGB spectrum in R Language - cm.colors() Function
- Generate a Vector of specified length with each element as a unique color on RG scale in RGB spectrum in R Language - terrain.colors() Function
- Convert an Object into a Vector in R Programming - as.vector() Function
- Check for the Existence of a Vector Object in R Programming - is.vector() Function
- Convert Colors from RGB to HSV in R Programming - rgb2hsv() Function
- Applying User-defined Functions on Factor Levels of Dataset in R Programming - by() Function
- Removing Levels from a Factor in R Programming - droplevels() Function
- Get the Number of Levels of a Factor in R Programming - nlevels() Function
- Generate Factors with specified Levels in R Programming - gl() Function
- Adding Colors to Charts in R Programming
- Add Leading Zeros to the Elements of a Vector in R Programming - Using paste0() and sprintf() Function
- Check if Elements of a Vector are non-empty Strings in R Programming - nzchar() Function
- Make Elements of a Vector Unique in R Programming - make.unique() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.