Get last value based on datetime variable

filter_date_last(.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.max) in the .date

See also

Other date functions: calc_age(), filter_date_first(), 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_last(adm_date) }