add_count | R Documentation |
Add a count column to the data frame.
df %>% add_count(a, b)
is equivalent to using df %>% mutate(n = n(), .by = c(a, b))
add_count(.df, ..., wt = NULL, sort = FALSE, name = NULL)
add_tally(.df, wt = NULL, sort = FALSE, name = NULL)
.df |
A data.frame or data.table |
... |
Columns to group by. |
wt |
Frequency weights.
Can be
|
sort |
If |
name |
The name of the new column in the output. If omitted, it will default to |
df <- data.table(
a = c("a", "a", "b"),
b = 1:3
)
df %>%
add_count(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.