# Example ungrouped
df <- tibble::tibble(
dt = as.Date("2020-01-01") + sample(0:1000, 100, TRUE)
)
dist_date(df, dt)
# Example grouped
df2 <- tibble::tibble(
dt = as.Date("2020-01-01") + sample(0:1000, 100, TRUE),
grp = sample(1:2, 100, TRUE)
)
dist_date(df2, dt, grp)
# Note this function accepts a pipe from dplyr eg. df %>% dist_date(date_var, group_var)
Run the code above in your browser using DataLab