Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pct

Helper for providing a numeric value as percentage


Description

A percentage value acts as a length value that is relative to an initial state. For instance an 80 percent value for something will size the target to 80 percent the size of its 'previous' value. This type of sizing is useful for sizing up or down a length value with an intuitive measure. This helper function can be used for the setting of font sizes (e.g., in cell_text()) and altering the thicknesses of lines (e.g., in cell_borders()). Should a more exact definition of size be required, the analogous helper function pct() will be more useful.

Usage

pct(x)

Arguments

x

the numeric value to format as a string percentage for some tab_options() arguments that can take percentage values (e.g., table.width).

Value

A character vector with a single value in percentage units.

Figures

Function ID

7-4

See Also

Examples

# Use `exibble` to create a gt table;
# use the `pct()` helper to define the
# font size for the column labels
tab_1 <-
  exibble %>%
  gt() %>%
  tab_style(
    style = cell_text(size = pct(75)),
    locations = cells_column_labels(columns = TRUE)
  )

gt

Easily Create Presentation-Ready Display Tables

v0.2.2
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>), Joe Cheng [aut], Barret Schloerke [aut] (<https://orcid.org/0000-0001-9986-114X>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.