Count observations by group
Returns row counts of the dataset. If bare column names are provided, count.()
returns counts by group.
count.(.df, ..., wt = NULL, sort = FALSE, name = NULL)
.df |
A data.frame or data.table |
... |
Columns to group by. |
wt |
Frequency weights.
|
sort |
If |
name |
The name of the new column in the output. If omitted, it will default to |
test_df <- data.table( x = 1:3, y = 4:6, z = c("a", "a", "b") ) test_df %>% count.() test_df %>% count.(z) test_df %>% count.(where(is.character)) test_df %>% count.(z, wt = y, name = "y_sum") test_df %>% count.(z, sort = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.