VOOZH about

URL: https://www.geeksforgeeks.org/r-language/get-the-hexadecimal-code-of-the-specified-shade-in-r-programming-rgb-function/

⇱ Get the Hexadecimal Code of the Specified Shade in R Programming - rgb() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Get the Hexadecimal Code of the Specified Shade in R Programming - rgb() Function

Last Updated : 15 Jul, 2025

rgb() function in R Language is used to specify the shade of the color red, green, and blue between 0 and 1. Further the specified shades of these three basic components will be mixed to form a new shade. The shade of the color red, green, and blue can also be specified between 0 and 255. But there will be an added argument max=255 while using this range. This function returns the corresponding hexadecimal code of the specified shade.
 

Syntax: rgb(a, b, c, max = 255) 
Parameters: 
a: shade of color red 
b: shade of color green 
c: shade of color blue 
max: added argument max=255 
 


Example 1: 
 

Output: 
 

[1] "#00FF80"
[1] "#E6B3CC"
[1] "#00B3FF"
[1] "#000000"
[1] "#FFFFFF"


Example 2: 
 

Output: 
 

[1] "#000000"
[1] "#05073C"
[1] "#FFFFFF"


 

Comment
Article Tags:

Explore