A thin wrapper around `print.data.table` that captures the printed representation of `x` and emits it with `message()` instead of writing to standard output. This is useful for reporting tabular information (e.g. diagnostics or warnings) through R's condition system so it can be suppressed, caught, or redirected like other messages. `before` and `after` allow adding explanatory text around the printed table.

message_dt(x, ..., before, after, sep = "\n")

Arguments

x

a data.table or something to be converted to a data.table.

...

passed to print.data.table.

before

optional text (character string) to prepend before the printed table in the message.

after

optional text (character string) to append after the printed table in the message.

sep

separator (character string) used to join `before`, the printed table, and `after`. Default is `"\n"`.

Details

defaults arguments to print.data.table (in addition to `x=dt` which cannot be overwritten) are `class=FALSE`, `print.keys=FALSE`, `row.names=FALSE`.