Is the "sorted" attribute part of the official data.table API?
I often do things like outputting a week / month / quarter / year variable from a date variable, which, of course, is a monotonous conversion. Then I do something using one of these monotonous derived variables.
I am wondering if it is possible to directly replace my date variable with the name of the week / month / etc. variables in a sorted attribute and that everything works correctly? i.e. safely below:
library(data.table) library(lubridate) DT <- data.table(day=as.Date(c('2006-01-30', '2006-01-31', '2006-02-01', '2006-02-02')), d=1:4, key='day') DT[, month := floor_date(day, unit='month')]
I could not understand if there were any other underlying data structures that reference the table that might cause problems with this technique.
r data.table
James
source share