n: The number of observations in the current group.

Description Usage Examples

View source: R/manip.r

Description

This function is implemented specifically for each data source and can only be used from within summarise(), mutate() and filter().

Usage

1
n()

Examples

1
2
3
4
5
6
if (require("nycflights13")) {
carriers <- group_by(flights, carrier)
summarise(carriers, n())
mutate(carriers, n = n())
filter(carriers, n() < 100)
}

Example output

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Loading required package: nycflights13
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'nycflights13'

dplyr documentation built on July 21, 2017, 1:01 a.m.

Search within the dplyr package
Search all R packages, documentation and source code