Helper function that can be used to find counts by group.
Can be used inside summarize()
, mutate()
, & filter()
n()
df <- data.table(
x = 1:3,
y = 4:6,
z = c("a","a","b")
)
df %>%
summarize(count = n(), .by = z)
#> # A tidytable: 2 × 2
#> z count
#> <chr> <int>
#> 1 a 2
#> 2 b 1