get_min_year: From an indicator for treatment, retrieve start year.

View source: R/panel.R

get_min_yearR Documentation

From an indicator for treatment, retrieve start year.

Description

This function returns the earliest year where an indicator == 1. If indicator never equals zero, return Inf. This is most useful with mutate(.by = unit, g = get_min_year(year, treat)) or DT(j = g := get_min_year(year, treat), by = unit) to convert between d and g variable in panel data.

Usage

get_min_year(t, d)

Arguments

t

Vector of years

d

Vector of 0/1 for treatment

Value

Returns earliest y for which t == 1


kylebutts/kfbmisc documentation built on April 17, 2025, 5:20 p.m.