% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verbs_grouping.R
\name{count}
\alias{count}
\alias{tally}
\title{Count observations by group}
\usage{
count(x, ..., wt = NULL, sort = FALSE, name = NULL)

tally(x, wt = NULL, sort = FALSE, name = NULL)
}
\arguments{
\item{x}{A \code{vectra_node} object.}

\item{...}{Grouping columns (unquoted).}

\item{wt}{Column to weight by (unquoted). If \code{NULL}, counts rows.}

\item{sort}{If \code{TRUE}, sort output in descending order of \code{n}.}

\item{name}{Name of the count column (default \code{"n"}).}
}
\value{
A \code{vectra_node} with group columns and a count column.
}
\description{
Count observations by group
}
\details{
Equivalent to \code{group_by(...) |> summarise(n = n())}. When \code{wt} is
provided, uses \code{sum(wt)} instead of \code{n()}. When \code{sort = TRUE}, results
are sorted in descending order of the count column.
}
\examples{
f <- tempfile(fileext = ".vtr")
write_vtr(mtcars, f)
tbl(f) |> count(cyl) |> collect()
unlink(f)

}
