From 1fb3c750f57ae20b2a82e96953a2e6dc5ad29d84 Mon Sep 17 00:00:00 2001 From: Nitish Jha <151559388+Nj221102@users.noreply.github.com> Date: Sun, 17 Mar 2024 00:38:39 +0530 Subject: [PATCH] Documentation for char.trunc('datatable.prettyprint.char') (#6005) * Documentation for char.trunc('datatable.prettyprint.char') * small fix * Mentioned trunc.char in 'print.data.table' function * Improved explanation * Update man/print.data.table.Rd Co-authored-by: Joshua Wu <124658199+joshhwuu@users.noreply.github.com> * Update man/print.data.table.Rd Co-authored-by: Joshua Wu <124658199+joshhwuu@users.noreply.github.com> * Update man/print.data.table.Rd Co-authored-by: Joshua Wu <124658199+joshhwuu@users.noreply.github.com> * added description, deleted from alias, usage, args * final touches * removed name of private function * removing space * Final tweaks --------- Co-authored-by: nitish jha Co-authored-by: Joshua Wu <124658199+joshhwuu@users.noreply.github.com> Co-authored-by: Michael Chirico --- man/print.data.table.Rd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/man/print.data.table.Rd b/man/print.data.table.Rd index b4929e789..304bbc999 100644 --- a/man/print.data.table.Rd +++ b/man/print.data.table.Rd @@ -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, @@ -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))