ave_dt: 'ave' for date objects

View source: R/utils.R

ave_dtR Documentation

ave for date objects

Description

Return date objects when ave tries to return integers.

Usage

ave_dt(x, ..., FUN = identity)

Arguments

x

an integer or date vector

...

grouping variables, typically factors, all of the same length as x

FUN

function to apply for each factor level combination

See Also

ave

Examples

set.seed(1)
dt <- Sys.Date() + sample(1:20, 20)
id <- rep(1:4, each = 5)

ave(dt, id, FUN = min)
ave_dt(dt, id, FUN = min)

ave(seq_along(dt), id, FUN = function(ii) dt[ii])
ave_dt(seq_along(dt), id, FUN = function(ii) dt[ii])


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.