count: Count observations by group

count_dtR Documentation

Count observations by group

Description

Count the unique values of one or more variables.

Usage

count_dt(.data, ..., sort = TRUE, .name = "n")

add_count_dt(.data, ..., .name = "n")

Arguments

.data

data.table/data.frame data.frame will be automatically converted to data.table.

...

Variables to group by, could receive what 'select_dt' receives.

sort

logical. If TRUE result will be sorted in desending order by resulting variable.

.name

character. Name of resulting variable. Default uses "n".

Value

data.table

See Also

count

Examples

iris %>% count_dt(Species)
iris %>% count_dt(Species,.name = "count")
iris %>% add_count_dt(Species)
iris %>% add_count_dt(Species,.name = "N")

mtcars %>% count_dt(cyl,vs)
mtcars %>% count_dt("cyl|vs")
mtcars %>% count_dt(cyl,vs,.name = "N",sort = FALSE)
mtcars %>% add_count_dt(cyl,vs)
mtcars %>% add_count_dt("cyl|vs")


tidyfst documentation built on Sept. 16, 2024, 9:06 a.m.