stata_N: Function to mimic the _N function in Stata

Description Usage Arguments Value Examples

Description

Function to mimic the _N function in Stata

Usage

1
stata_N(df, idvar, counter_name = "N")

Arguments

df

Your dataframe

idvar

A string containing the name of the group variable

counter_name

The name of the counter variable. Defaults to "N".

Value

Your dataframe but with at counter with the name according to counter_name

Examples

1
2
df <- data.frame(id = c("A", "A", "B", "B", "B", "C", "C"), val = rnorm(7))
df <- stata_N(df, "id")

Steensson/valhalla documentation built on May 6, 2019, 5:59 p.m.