count: Count rows by group

View source: R/aggregate.R

countR Documentation

Count rows by group

Description

Count rows in a table by one or more grouping columns.

Usage

count(data, by, sort = TRUE, name = "n", ...)

Arguments

data

A data frame, or a single path to a delimited text file for the fused one-pass file mode.

by

Character vector of grouping columns.

sort

Whether to sort by descending counts. Ties (groups with the same count) are broken by ascending group key, so the row order is fully determined by by and data – never by the grouping engine's internal enumeration order, which is otherwise unspecified.

name

Name of the count column.

...

In file mode, reader options such as where, delim.

Value

A basetable with one row per group.


basetable documentation built on Sept. 18, 2026, 9:13 a.m.