描述
计算一个或多个变量的唯一值
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
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,.name = "N",sort = FALSE)
mtcars %>% add_count_dt(cyl,vs)