Learn R Programming

colouR (version 0.1.1)

avgHex: avgHex

Description

Average Hex Colors per Group. This function takes a data frame with two columns: one for the hex color values and another for the group labels. It calculates the average color for each group and returns a data frame with the group labels and their corresponding average hex colors.

Usage

avgHex(df, hex_col, group_col)

Value

A data frame with the group labels and their corresponding average hex colors.

Arguments

df

A data frame with columns for hex color values and group labels.

hex_col

The name of the column containing hex color values. Default is "hex".

group_col

The name of the column containing group labels. Default is "group".

Examples

Run this code
df <- data.frame(
  hex = c("#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF"),
  group = c(1, 1, 2, 2, 3)
)

avgHex(df, hex_col = "hex", group_col = "group")

Run the code above in your browser using DataLab