count {tidytable} | R Documentation |
Count observations by group
Description
Returns row counts of the dataset.
tally()
returns counts by group on a grouped tidytable.
count()
returns counts by group on a grouped tidytable, or column names can be specified
to return counts by group.
Usage
count(.df, ..., wt = NULL, sort = FALSE, name = NULL)
tally(.df, wt = NULL, sort = FALSE, name = NULL)
Arguments
.df |
A data.frame or data.table |
... |
Columns to group by in |
wt |
Frequency weights.
|
sort |
If |
name |
The name of the new column in the output. If omitted, it will default to |
Examples
df <- data.table(
x = c("a", "a", "b"),
y = c("a", "a", "b"),
z = 1:3
)
df %>%
count()
df %>%
count(x)
df %>%
count(where(is.character))
df %>%
count(x, wt = z, name = "x_sum")
df %>%
count(x, sort = TRUE)
df %>%
tally()
df %>%
group_by(x) %>%
tally()
[Package tidytable version 0.11.1 Index]