n.: Number of observations in each group

Description Usage Examples

View source: R/n.R

Description

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

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

Usage

1
n.()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
test_df <- data.table(
  x = 1:3,
  y = 4:6,
  z = c("a","a","b")
 )

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

# The dplyr version `n()` also works
test_df %>%
  summarize.(count = n(), .by = z)

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.