count() groups the data by the given columns and counts the
rows in each group. tally() counts rows for the existing grouping set by
group_by() without adding new grouping columns. Both build on the
group_by()/summarise() machinery and run in the browser.
Usage
# S3 method for class 'tbl_lazy_json'
count(x, ..., wt = NULL, sort = FALSE, name = NULL)
# S3 method for class 'tbl_lazy_json'
tally(x, wt = NULL, sort = FALSE, name = NULL)Arguments
- x
A
tbl_lazy_jsonobject.- ...
Columns to group by before counting (for
count()). Accepts the same inputs asgroup_by().- wt
Not supported; weighted counts are not implemented for
tbl_lazy_json. Supplying a non-NULLvalue raises an error.- sort
If
TRUE, order the result by the count column descending.- name
Name of the count column in the output.
NULLuses"n".
Value
A tbl_lazy_json object with the count appended as a lazy compute
step. When evaluated it yields one row per group with the count column
(named by name, default "n") added.
Examples
if (interactive()) {
tbl(session, "mtcars") |> count(cyl)
tbl(session, "mtcars") |> count(cyl, sort = TRUE)
tbl(session, "mtcars") |> group_by(cyl) |> tally()
}
