Learn R Programming

colouR (version 0.1.1)

groupCols: groupCols

Description

Group Hex Colors. This function takes a vector of hex color values and groups them using k-means clustering in the RGB color space. It returns a data frame with the original hex colors and their assigned group labels.

Usage

groupCols(hex_colors, n_clusters = 5)

Value

A data frame with the original hex colors and their assigned group labels.

Arguments

hex_colors

A character vector of hex color values.

n_clusters

The number of clusters (groups) to use in the k-means clustering. Default is 5.

Examples

Run this code
hex_colors <- c("#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF")
groupCols(hex_colors, n_clusters = 2)

Run the code above in your browser using DataLab