Skip to content

Keep Date class when performing a mean calculation #1023

@DavidArenburg

Description

@DavidArenburg
library(data.table)
DT <- data.table(Period = rep(1:3, each = 3), Date = as.Date(seq(Sys.Date(), (Sys.Date() + 8), by = "day")))

aggregate(Date ~ Period, DT, mean)
#   Period       Date
#1      1 2015-01-28
#2      2 2015-01-31
#3      3 2015-02-03

DT[, .(mean(Date)), Period]
#    Period    V1
#1:      1 16463
#2:      2 16466
#3:      3 16469

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions