I noticed this slightly odd behavior.
I've created a data.table by stringing together multiple blocks of [i, j, by]
operations, and in the last one I'm using the :=
assignment operator. But now that data.table doesn't print to console, unless you nudge it to do so with []
Example:
set.seed(1)
raw_dt <- data.table(x = sample(letters[1:5], 50, replace=T))
new_dt <- raw_dt[, .N, by = x][, label := paste(x, 'occurs', N, 'times')]
# this does not print to console
new_dt
# although this does
new_dt[]
It's good that :=
operations don't print, so you can use them silently in markdown chunks, but I would have expected a new DT assigned like the one above to still print.
[]
is a fine workaround, but is this intended behaviour? Any way to get new_dt
above to print when invoked by itself, without []
?