order_cat_b {diceplot} | R Documentation |
Order Category B
Description
Determines the ordering of category B based on the counts within each group, ordered by group and count.
Usage
order_cat_b(data, group, cat_b, group_colors, reverse_order = FALSE)
Arguments
data |
A data frame containing the variables. |
group |
The name of the column representing the grouping variable. |
cat_b |
The name of the column representing category B. |
group_colors |
A named vector of colors for each group. The names correspond to group names. |
reverse_order |
Reverse the ordering? Default is FALSE. |
Value
A vector of category B labels ordered according to group and count.
Examples
library(dplyr)
data <- data.frame(
group = rep(c("G1", "G2"), each = 5),
cat_b = sample(LETTERS[1:3], 10, replace = TRUE)
)
group_colors <- c("G1" = "red", "G2" = "blue")
order_cat_b(data, "group", "cat_b", group_colors)
[Package diceplot version 0.2.0 Index]