Printing prt
Printing of prt
objects combines the concise yet informative design
of only showing as many columns as the terminal width allows for, introduced
by tibble
, with the data.table
approach of showing both the first and
last few rows of a table. Implementation wise, the interface is designed to
mimic that of tibble
printing as closely as possibly, offering the same
function arguments and using the same option settings (and default values)
as introduced by tibble
.
## S3 method for class 'prt' print(x, ..., n = NULL, width = NULL, n_extra = NULL) ## S3 method for class 'prt' format(x, ..., n = NULL, width = NULL, n_extra = NULL) trunc_dt(x, n = NULL, width = NULL, n_extra = NULL)
x |
Object to format or print. |
... |
Other arguments passed on to individual methods. |
n |
Number of rows to show. If |
width |
Width of text output to generate. This defaults to |
n_extra |
Number of extra columns to print abbreviated information for,
if the width is too small for the entire tibble. If |
While the function tibble::trunc_mat()
does most of the heavy lifting
for formatting tibble
printing output, prt
exports the function
trunc_dt()
, which drives analogous functionality while adding the
top/bottom n
row concept. This function can be used for creating print()
methods for other classes which represent tabular data, given that this
class implements dim()
, head()
and tail()
(and optionally
tibble::tbl_sum()
) methods. For an example of this, see
vignette("prt", package = "prt")
.
The following session options are set by tibble
and are respected by
prt
, as well as any other package that were to call trunc_dt()
:
tibble.print_max
: Row number threshold: Maximum number of rows printed.
Set to Inf
to always print all rows. Default: 20.
tibble.print_min
: Number of rows printed if row number threshold is
exceeded. Default: 10.
tibble.width
: Output width. Default: NULL
(use width
option).
tibble.max_extra_cols
: Number of extra columns printed in reduced form.
Default: 100.
Both tibble
and prt
rely on pillar
for formatting columns and
therefore, the following options set by pillar
are applicable to prt
printing as well.
pillar.bold
: Use bold font, e.g. for column headers? This currently
defaults to FALSE
, because many terminal fonts have poor support for
bold fonts.
pillar.subtle
: Use subtle style, e.g. for row numbers and data types?
Default: TRUE
.
pillar.subtle_num
: Use subtle style for insignificant digits? Default:
FALSE
, is also affected by the pillar.subtle
option.
pillar.neg
: Highlight negative numbers? Default: TRUE
.
pillar.sigfig
: The number of significant digits that will be printed and
highlighted, default: 3
. Set the pillar.subtle
option to FALSE
to
turn off highlighting of significant digits.
pillar.min_title_chars
: The minimum number of characters for the column
title, default: 15
. Column titles may be truncated up to that width to
save horizontal space. Set to Inf
to turn off truncation of column
titles.
pillar.min_chars
: The minimum number of characters wide to
display character columns, default: 0
. Character columns may be
truncated up to that width to save horizontal space. Set to Inf
to
turn off truncation of character columns.
cars <- as_prt(mtcars) print(cars) print(cars, n = 2) print(cars, width = 30) print(cars, width = 30, n_extra = 2)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.