Like uniq -c in shell to count a vector

count2(df)

Arguments

df

two columns: first is type, second is number

Value

two columns: first is type, second is number

Examples

count2(data.frame(group = c("A", "A", "B", "C", "C", "A"), value = c(2, 2, 2, 1, 3, 1)))
#>   group value
#> 1     A     4
#> 2     B     2
#> 3     C     4
#> 4     A     1