powered by
This is a method for the dplyr count() generic. It is translated using .N in the j argument, and supplying groups to keyby as appropriate.
count()
.N
j
keyby
# S3 method for dtplyr_step count(.data, ..., wt = NULL, sort = FALSE, name = NULL)
A lazy_dt()
lazy_dt()
<data-masking> Variables to group by.
data-masking
<data-masking> Frequency weights. Can be NULL or a variable:
NULL
If NULL (the default), counts the number of rows in each group.
If a variable, computes sum(wt) for each group.
sum(wt)
If TRUE, will show the largest groups at the top.
TRUE
The name of the new column in the output.
If omitted, it will default to n. If there's already a column called n, it will error, and require you to specify the name.
n
# NOT RUN { library(dplyr, warn.conflicts = FALSE) dt <- lazy_dt(dplyr::starwars) dt %>% count(species) dt %>% count(species, sort = TRUE) dt %>% count(species, wt = mass, sort = TRUE) # }
Run the code above in your browser using DataLab