% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verbs_grouping.R
\name{summarise}
\alias{summarise}
\alias{summarize}
\title{Summarise grouped data}
\usage{
summarise(.data, ..., .groups = NULL)

summarize(.data, ..., .groups = NULL)
}
\arguments{
\item{.data}{A grouped \code{vectra_node} (from \code{\link[=group_by]{group_by()}}).}

\item{...}{Named aggregation expressions using \code{n()}, \code{sum()}, \code{mean()},
\code{min()}, \code{max()}, \code{sd()}, \code{var()}, \code{first()}, \code{last()}, \code{any()}, \code{all()},
\code{median()}, \code{n_distinct()}.}

\item{.groups}{How to handle groups in the result. One of \code{"drop_last"}
(default), \code{"drop"}, or \code{"keep"}.}
}
\value{
A \code{vectra_node} with one row per group.
}
\description{
Summarise grouped data
}
\details{
Aggregation is hash-based by default. When the engine detects it is
advantageous, it switches to a sort-based path that can spill to disk,
keeping memory bounded regardless of group count.

All aggregation functions accept \code{na.rm = TRUE} to skip NA values.
Without \code{na.rm}, any NA in a group poisons the result (returns NA).
R-matching edge cases: \code{sum(na.rm = TRUE)} on all-NA returns 0,
\code{mean(na.rm = TRUE)} on all-NA returns NaN, \code{min/max(na.rm = TRUE)} on
all-NA returns Inf/-Inf with a warning.

This is a materializing operation.
}
\examples{
f <- tempfile(fileext = ".vtr")
write_vtr(mtcars, f)
tbl(f) |> group_by(cyl) |> summarise(avg_mpg = mean(mpg)) |> collect()
unlink(f)

}
