I'm trying to split data according to 15-minute timestamps; my approach is:
library(data.table)
set.seed(210349)
DT = data.table(t = sample(10000, 100), V = rnorm(100))
# t is in seconds, so 900 seconds is 15 minutes
DT[ , ID := .GRP, keyby = .(t %/% 900L)]
Warning message:
In [.data.table(DT, , :=(ID, .GRP), keyby = .(t%/%900L)) :
:= keyby not straightforward character column names or list() of column names, treating as a by:t%/%900
It's weird that this gives me a warning since it's purely related to the use of keyby:
# (no warning)
DT[order(t), ID := .GRP, by = .(t %/% 900L)]
(i in this case doesn't need to match that in by exactly)
For sanity:
DT[ , ID := .GRP, keyby = .(t %/% 900L)]
DT[order(t), ID2 := .GRP, by = .(t %/% 900L)]
DT[ , identical(ID, ID2)]
# [1] TRUE
What's the reason for this warning?
I'm trying to split data according to 15-minute timestamps; my approach is:
It's weird that this gives me a warning since it's purely related to the use of
keyby:(
iin this case doesn't need to match that inbyexactly)For sanity:
What's the reason for this warning?