Learn R Programming

rifttable (version 0.7.2)

rt_gt: Turn tibble into gt Table with Custom Formatting

Description

Formatting includes:

  • Text align to top/left

  • Smaller row padding

  • No top border

  • Bold column labels

If this function is called within a document that is being knit to plain markdown, such as format: gfm in a Quarto document or format: github_document in an RMarkdown document, then a plain markdown-formatted table (e.g., without footnotes) is returned via kable.

Usage

rt_gt(df, md = 1, indent = 10, remove_border = TRUE)

Value

Formatted gt table

Arguments

df

Data frame/tibble

md

Optional. If not NULL, then the given columns will be printed with markdown formatting, e.g., md = c(1, 3) for columns 1 and 3. Defaults to 1, i.e., the first column.

indent

Optional. Detects cells in the first column of table, e.g., from rifttable where the first column contains the labels, that start with at least two spaces. This text is then indented via tab_style. Defaults 10 for 10 pixels. Set to NULL to turn off.

remove_border

Optional. For rows that are indented in the first column or have an empty first column, remove the upper horizontal border line? Defaults to TRUE.

Examples

Run this code
data(mtcars)
mtcars |>
  dplyr::slice(1:5) |>
  rt_gt()

Run the code above in your browser using DataLab