add_n_obs: Add the number of observations for each key in a 'tsibble'

View source: R/n-obs.R

add_n_obsR Documentation

Add the number of observations for each key in a tsibble

Description

Here, we are not counting the number of rows in the dataset, but rather we are counting the number observations for each keys in the data.

Usage

add_n_obs(.data, ...)

Arguments

.data

tsibble

...

extra arguments

Value

tsibble with n_obs, the number of observations per key added.

Examples

library(dplyr)
# you can explore the data to see those cases that have exactly two
 # observations:
heights %>%
  add_n_obs() %>%
  filter(n_obs == 2)

njtierney/brolgar documentation built on June 2, 2025, 6:20 a.m.