Submitted by: Garrett See; Assigned to: Nobody; R-Forge link
Note that in the output below the values in V1 are only 6 digits long
library(data.table)
dat <- data.table(Date=c(20131101:20131130, 20131201:20131231))
dat[, last(Date), by=Date %/% 100L]
# Date V1
#1: 201311 201311
#2: 201312 201312
I thought it should give the same results as this:
dat[, last(Date), by=substr(Date, 1, 6)]
# substr V1
#1: 201311 20131130
#2: 201312 20131231