[datatable-help] Avoiding print when using := ?

Allan Engelhardt allane at cybaea.com
Thu Sep 13 23:16:25 CEST 2012


Is there any way of tuning off the printing when using the := 
assignment? I have taken to writing code like

library("data.table")
DT <- data.table(idx = 1:10, key = "idx")
for (i in 1) { # Avoid default print
     DT[, v := runif(idx)]
}

just to avoid cluttering my screen. I could of course wrap it in 
invisible() instead, though I am not sure that makes for much cleaner 
code, or use

DT$v <- with(DT, runif(idx))

when adding new columns. But I thought := was clever and used an 
overallocation trick, and I of course wanted to benefit from this.

Allan




More information about the datatable-help mailing list