View source: R/calc_rcsize.bare.R
calc_rcsize | R Documentation |
Calculate the display widths (in mm) of each table column, heights of each
table row, and horizontal and vertical dimensions of each table entry.
Calculations may use the constraints imposed by minwidth
and
maxwidth
for each entry. This is an internal utility function, not
intended to be called by package users.
calc_rcsize(entryInfo, vrule_hsize, hrule_vsize, sizeAdjust,
nominal_rcmin, method)
entryInfo |
A |
vrule_hsize |
Numeric vector with length (# table columns) + 1, giving the horizontal dimensions, in mm, of vertical rules in the table. |
hrule_vsize |
Numeric vector with length (# table rows) + 1, giving the vertical dimensions, in mm, of horizontal rules in the table. |
sizeAdjust |
Two-element numeric vector containing multipliers to adjust the calculated absolute size of table text, when determining row and column sizes. Essentially fudge factors. The first element is applied to the horizontal dimension and the second to the vertical dimension. |
nominal_rcmin |
A nominal minimum size for any row or column, in mm. It is used to avoid
division by 0 when calculating the proportional change in size due to
constraints, when |
method |
Which algorithm/objective function is used for the constrained optimization problem.
|
Entries can span multiple columns and rows, and can have constraints on
their minimum and maximum widths. This function calculates row and column
dimensions that satisfy the constraints while minimizing an objective
function that measures deviations from their natural sizes. They are the
solution to a quadratic programming problem. An error will be raised if
the QP has no solution (e.g., if minwidth
and maxwidth
collectively, over all entries, are inconsistent).
minwidth
and maxwidth
are in the text's frame of reference,
and may be expressed in two forms. Positive values are interpreted as
absolute widths in millimeters, and *should* include the amount of any
padding specified by hpad
(when angle
is 0 or 180 degrees)
or vpad
(when angle
is 90 or 270 degrees), as well as
scaling by sizeAdjust
. Negative values are interpreted as
multiples of the natural text width without wrapping and *without*
including padding or sizeAdjust
. Thus setting minwidth
for
an entry to -1 will guarantee that the width of the spanned cell(s) will
be at least enough to contain it without wrapping.
An NA
value for minwidth
means there is no constraint on minimum width,
and is equivalent to 0. An Inf
value for maxwidth
means
there is no constraint on maximum width. In the absence of constraints,
the internal algorithm favors widths as close as possible to the natural
width of the entry text, without wrapping.
An NA value for
maxwidth
means the maximum width will be determined passively from
the maxwidth
values of other entries in the same table column(s)
(if angle
is 0 or 180) or row(s) (if angle
is 90 or 270).
(It will never be less than minwidth
.) This may be useful for table
titles and footnotes, where long text should be wrapped to fit widths
implied by the other table entries.
Setting maxwidth
to NA or
to a finite value > -1
and < Inf
means the spanned cell(s)
may not be wide enough to hold the text without wrapping it into multiple
lines.
The general effect of setting minwidth
to a non-zero
value is to reduce or prevent text wrapping, while the general effect of
setting maxwidth
to NA or a finite value is to encourage wrapping.
Settings for one entry may affect the width and wrapping of other entries,
because column widths and row heights for the table as a whole must
satisfy the constraints for all their entries.
Text representing
plotmath
expressions cannot be wrapped, so maxwidth
should
be Inf
or <= -1
for such entries.
method=0
ignores minwidth
and maxwidth
when
determining row and column sizes. However a warning will be raised if the
resulting sizes violate the constraints for any enabled entries.
List with components:
hsizeCol |
Numeric vector of display widths for each table column, in mm. |
vsizeRow |
Numeric vector of display heights for each table row, in mm. |
sizeInfo |
Data frame with one row per table entry. Columns are |
Operation of this function is controlled by parameters in internal object
internalOpt
, specifically those with prefix rcsize_
. Values
of option rcsize_verbose
greater than 2 will cause a data frame of
calculated entry widths to be written to the global environment for each
iteration.
Among methods 2-5, 2 and 4 seem best because they do not alter the target
size in the numerator; method 5 encourages expanding row *and* column
sizes by rcsize_rcmin
even when no wrapping is required in a given
direction.
entrySize_mm
, called by this function to calculate the sizes
in sizeInfo
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.