| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/multi.R |
| 3 |
\name{colonnade} |
| 4 |
\alias{colonnade} |
| 5 |
\title{Format multiple vectors in a tabular display} |
| 6 |
\usage{ |
| 7 |
colonnade(x, has_row_id = TRUE, width = NULL, ...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{x}{A list, which can contain matrices or data frames. |
| 11 |
If named, the names will be used as title for the pillars. Non-syntactic names |
| 12 |
will be escaped.} |
| 13 |
|
| 14 |
\item{has_row_id}{Include a column indicating row IDs? Pass \code{"*"} to mark |
| 15 |
the row ID column with a star.} |
| 16 |
|
| 17 |
\item{width}{Default width of the entire output, optional.} |
| 18 |
|
| 19 |
\item{...}{These dots are for future extensions and must be empty.} |
| 20 |
} |
| 21 |
\description{ |
| 22 |
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#soft-deprecated}{\figure{lifecycle-soft-deprecated.svg}{options: alt='[Soft-deprecated]'}}}{\strong{[Soft-deprecated]}} |
| 23 |
|
| 24 |
The vectors are formatted to fit horizontally into a user-supplied number of |
| 25 |
characters per row. |
| 26 |
|
| 27 |
The \code{colonnade()} function doesn't process the input but returns an object |
| 28 |
with a \code{\link[=format]{format()}} and a \code{\link[=print]{print()}} method. |
| 29 |
The implementations call \code{\link[=squeeze]{squeeze()}} to create \link{pillar} objects and fit them to a given width. |
| 30 |
} |
| 31 |
\details{ |
| 32 |
Pillars may be distributed over multiple tiers if |
| 33 |
\code{width > getOption("width")}. In this case each tier is at most |
| 34 |
\code{getOption("width")} characters wide. The very first step of formatting |
| 35 |
is to determine how many tiers are shown at most, and the width of each |
| 36 |
tier. |
| 37 |
|
| 38 |
To avoid unnecessary computation for showing very wide colonnades, a first |
| 39 |
pass tries to fit all capitals into the tiers. |
| 40 |
For each pillar whose capital fits, it is then decided in which tier it is |
| 41 |
shown, if at all, and how much horizontal space it may use (either its |
| 42 |
minimum or its maximum width). |
| 43 |
Remaining space is then distributed proportionally to pillars that do not |
| 44 |
use their desired width. |
| 45 |
|
| 46 |
For fitting pillars in one or more tiers, first a check is made |
| 47 |
if all pillars fit with their maximum width (e.g., |
| 48 |
\code{option(tibble.width = Inf)} or narrow colonnade). |
| 49 |
If yes, this is the resulting fit, no more work needs to be done. |
| 50 |
Otherwise, if the maximum width is too wide, the same test |
| 51 |
is carried out with the minimum width. |
| 52 |
If this is still too wide, this is the resulting fit. |
| 53 |
Otherwise, some tiers from the start |
| 54 |
will contain pillars with their maximum width, |
| 55 |
one tier will contain some pillars with maximum and some with minimum width, |
| 56 |
and the remaining tiers contain pillars with their minimum width only. |
| 57 |
|
| 58 |
For this, we compute a "reverse minimum assignment". |
| 59 |
|
| 60 |
We determine the cut point where minimum and maximum assignment |
| 61 |
agree. |
| 62 |
The following strategy is applied: |
| 63 |
\enumerate{ |
| 64 |
\item First, we determine the tier in which the cut point lies. |
| 65 |
This is the first instance of a column that ends up in the same tier |
| 66 |
for both minimum and maximum assignment. |
| 67 |
\item A set of candidate cut points is derived. |
| 68 |
\item We consult the column offsets. The last column where the minimum assignment |
| 69 |
has a greater or equal offset than the maximum assignment is our latest |
| 70 |
cut point. |
| 71 |
If no such column exists, the cut point is the column just before our |
| 72 |
first candidate. |
| 73 |
\item Finally, we combine maximum and minimum reverse fits at the cut point. |
| 74 |
We don't need to redistribute anything here. |
| 75 |
} |
| 76 |
|
| 77 |
Fitting pillars into tiers is very similar to a word-wrapping algorithm. |
| 78 |
In a loop, new tiers are opened if the current tier overflows. |
| 79 |
If a column is too wide to fit a single tier, it will never be |
| 80 |
displayed, and the colonnade will be truncated there. |
| 81 |
This case should never occur with reasonable display widths larger than |
| 82 |
30 characters. |
| 83 |
Truncation also happens if all available tiers are filled. |
| 84 |
|
| 85 |
The remaining space is distributed from left to right. |
| 86 |
Each column gains space proportional to the fraction of missing and |
| 87 |
remaining space, |
| 88 |
rounded down. |
| 89 |
Any space remaining after rounding is distributed from left to right, |
| 90 |
one space per column. |
| 91 |
} |
| 92 |
\keyword{internal} |