Skip to content
10 changes: 10 additions & 0 deletions man/print.data.table.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Key enhancements include automatic output compression of many observations and concise column-wise \code{class} summary.

\code{format_col} and \code{format_list_item} generics provide flexibility for end-users to define custom printing methods for generic classes.

Note also the option \code{datatable.prettyprint.char}; character columns entries exceeding this limit will be truncated, with \code{...} indicating the truncation.
}
\usage{
\method{print}{data.table}(x,
Expand Down Expand Up @@ -98,6 +100,14 @@
print(DT, trunc.cols=TRUE)
options(old_width)

# `char.trunc` will truncate the strings if their lengths exceed the given limit: `datatable.prettyprint.char`
# For example:

old = options(datatable.prettyprint.char=5L)
DT = data.table(x=1:2, y=c("abcdefghij", "klmnopqrstuv"))
DT
options(old)

# Formatting customization
format_col.complex = function(x, ...) sprintf('(\%.1f, \%.1fi)', Re(x), Im(x))
x = data.table(z = c(1 + 3i, 2 - 1i, pi + 2.718i))
Expand Down