avgHex | R Documentation |
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.
avgHex(df, hex_col, group_col)
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". |
A data frame with the group labels and their corresponding average hex colors.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.