Skip to contents

Totals value per group and keeps the n largest, largest first, and of equal ones the first by name. Groups that are NA, or whose total is 0 or less, are left out. With other, the rest are kept too, as one group, "Other", last: a ring shows the whole.

Usage

group_top(group, value, n = 5, other = FALSE)

Arguments

group

The group of each value, such as its repository or its language.

value

The values.

n

The number of groups to keep.

other

Keep the rest as "Other"? One group more than n is kept as it is.

Value

A data frame of label and value.

Examples

rghcard:::group_top(c("R", "Python", "R", NA, "Shell"), c(1, 1, 1, 1, 1), n = 2)
#>    label value
#> 1      R     2
#> 2 Python     1
rghcard:::group_top(c("R", "Python", "R", "Shell", "TeX"), c(1, 1, 1, 1, 1), n = 2, other = TRUE)
#>    label value
#> 1      R     2
#> 2 Python     1
#> 3  Other     2