opt_row_striping: Option to add or remove row striping

View source: R/opts.R

opt_row_stripingR Documentation

Option to add or remove row striping

Description

By default, a gt table does not have row striping enabled. However, this function allows us to easily enable or disable striped rows in the table body. This function serves as a convenient shortcut for ⁠<gt_tbl> |> tab_options(row.striping.include_table_body = TRUE|FALSE)⁠.

Usage

opt_row_striping(data, row_striping = TRUE)

Arguments

data

The gt table data object

⁠obj:<gt_tbl>⁠ // required

This is the gt table object that is commonly created through use of the gt() function.

row_striping

Use alternating row stripes

⁠scalar<logical>⁠ // default: TRUE

A logical value to indicate whether row striping should be added or removed.

Value

An object of class gt_tbl.

Examples

Use the exibble dataset to create a gt table with a number of table parts added (using functions like summary_rows(), grand_summary_rows(), and more). Following that, we'll add row striping to every second row with opt_row_striping().

exibble |>
  gt(rowname_col = "row", groupname_col = "group") |>
  summary_rows(
    groups = "grp_a",
    columns = c(num, currency),
    fns = c("min", "max")
  ) |>
  grand_summary_rows(
    columns = currency,
    fns = total ~ sum(., na.rm = TRUE)
  ) |>
  tab_source_note(source_note = "This is a source note.") |>
  tab_footnote(
    footnote = "This is a footnote.",
    locations = cells_body(columns = 1, rows = 1)
  ) |>
  tab_header(
    title = "The title of the table",
    subtitle = "The table's subtitle"
  ) |>
  opt_row_striping()
This image of a table was generated from the first code example in the `opt_row_striping()` help file.

Function ID

10-5

Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other table option functions: opt_align_table_header(), opt_all_caps(), opt_css(), opt_footnote_marks(), opt_footnote_spec(), opt_horizontal_padding(), opt_interactive(), opt_stylize(), opt_table_font(), opt_table_lines(), opt_table_outline(), opt_vertical_padding()


rstudio/gt documentation built on Dec. 2, 2024, 11:05 a.m.