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

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Sep 14 00:42:09 CEST 2012


Hi,

On Thu, Sep 13, 2012 at 6:15 PM, Bacou, Melanie <mel at mbacou.com> wrote:
> Just to echo Allan's request -- I think many of us data.table users do work
> interactively at times, so the default `:=` print behavior can be a problem
> with large tables.
>
> What would be the cons of using a default print behavior for `:=` that only
> prints top and last `n` rows as in data.table:::print.data.table ?

It already does this:

R> library(data.table)
R> dt = data.table(a=rnorm(200), b=sample(letters, 200, rep=T))
R> dt[, y := runif(200)]

              a b         y
  1:  0.1486739 m 0.4442021
  2: -1.2787850 y 0.9538030
  3: -1.6507274 y 0.3171195
  4: -0.1445559 d 0.2074747
  5:  0.9884454 m 0.3392145
 ---
196:  1.0310931 i 0.7000658
197:  1.4269618 k 0.4968695
198:  1.0283900 s 0.7806085
199: -0.6082233 v 0.3105555
200:  0.8320824 q 0.7372878

The `---` cutting kicks in if the nrow(data.table) > 100, (see the
`nrows` param in data.table:::print.data.table).

Perhaps the `nrows` param in print.data.table should be user
configurable by some `option`, maybe something like:

print.data.table <- function(x,
nrows=getOption('datatable.print.nrows', 100), ...) { ... }

Then you could `options(datatable.print.nrows=20)` if 100 is too high ...

Maybe?

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the datatable-help mailing list