Skip to content

Confusing warning message #2763

@MichaelChirico

Description

@MichaelChirico

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions