Flag a firm's chronologically first occurrence of a 0/1 event
Source:R/utils-panel.R
first_occurrence_flag.RdReturns 1 only on the earliest time value (per id) at which x == 1
— not the first row of each subsequent episode, the single first
occurrence ever. NA values in x are treated as "not an event" and do
not break the chain (matching Stata's sum() treating missing as 0 in
the cumulative-sum idiom the source uses for this same purpose — see
Pseudocode/00_conventions.md, FIRST_OCCURRENCE_FLAG).