Skip to contents

For each row group of a share table (from PlotDataCrossShares()), finds the category with the largest share (ties go to the earlier category in columns) and orders the groups by the position of that category in priority, then by the group value. Categories missing from priority take position zero, before all listed ones. A group without any share among columns has a missing dominant category and also takes position zero.

Usage

PlotDataDominant(
  data,
  row,
  column,
  value = "share",
  columns = NULL,
  priority = NULL
)

Arguments

data

Long share table.

row, column, value

Column names.

columns

Category order used to break ties.

priority

Category order defining the group order.

Value

A data frame with the group, dominant, dominant_share and rank, sorted by rank.

Examples

s <- PlotDataCrossShares(data.frame(cl = c(1, 1, 2, 3), type = c("b", "b", "a", "b")), "cl", "type")
PlotDataDominant(s, "cl", "type", "share", columns = c("a", "b"), priority = c("a", "b"))
#>   cl dominant dominant_share rank
#> 1  2        a            100    1
#> 2  1        b            100    2
#> 3  3        b            100    3