n: Number of observations in each group

View source: R/n.R

nR Documentation

Number of observations in each group

Description

Helper function that can be used to find counts by group.

Can be used inside summarize(), mutate(), & filter()

Usage

n()

Examples

df <- data.table(
  x = 1:3,
  y = 4:6,
  z = c("a","a","b")
 )

df %>%
  summarize(count = n(), .by = z)

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.