Get first value based on datetime variable

filter_date_first(.data, date_var)

Arguments

.data

data which contains datetime or other comparable variable

date_var

datetime or other comparable variable

Value

The row which is the first (by which.min) in the .date

See also

Other date functions: calc_age(), filter_date_last(), filter_date_nearest()

Examples

if (FALSE) { # searching for the first event of the each class (for each individual): dat %>% filter(!is.na(label)) %>% group_by(personid,label) %>% filter_date_first(adm_date) }