| pretty_widths | R Documentation |
pretty_widths() sets each column's width to fit its contents and then
scales the widths so that the table has the width given by table_width.
pretty_widths(
x,
min_width = 0.05,
unit = c("in", "cm", "mm"),
table_width = NULL
)
x |
flextable |
min_width |
minimum width of columns |
unit |
unit of the column widths: |
table_width |
width of the table, in the same forms in every apa7
function: a proportion from 0 to 1 of the default width (the full width
of a portrait page unless changed with |
The widths are first measured with flextable::dim_pretty(), and no column
is narrower than min_width. If the table width is 0, these widths are kept.
Otherwise, they are scaled up or down in proportion so that they add up to
the table width, with two exceptions:
Break columns (from add_break_columns()) are kept at min_width.
List columns (from add_list_column()) keep their measured width, and the
column to the right of each one (the text of the list) gets the extra width
instead.
The table's layout is then set to "fixed", so that Word keeps the widths.
If table_width is NULL (default), the width is taken from the code
chunk's options or from apa7_defaults() (see the table_width argument).
With the defaults, the table is as wide as the text on a portrait page.
flextable::flextable
ft <- flextable::flextable(head(mtcars[, 1:4]))
# Widths fitted to the contents
pretty_widths(ft)
# Widths stretched to a total of 4 inches
pretty_widths(ft, table_width = c(inches = 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.