gt_duplicate_column: Duplicate an existing column in a gt table

View source: R/gt_duplicate_column.R

gt_duplicate_columnR Documentation

Duplicate an existing column in a gt table

Description

This function takes an existing gt table and will duplicate a column. You also have the option to specify where the column ends up, and what will be appending to the end of the column name to differentiate it.

Usage

gt_duplicate_column(
  gt_object,
  column,
  after = dplyr::last_col(),
  append_text = "_dupe",
  dupe_name = NULL
)

Arguments

gt_object

An existing gt table object of class gt_tbl

column

The column to be duplicated

after

The column to place the duplicate column after

append_text

The text to add to the column name to differentiate it from the original column name

dupe_name

A full name for the "new" duplicated column, will override append_text

Value

An object of class gt_tbl.

Function ID

2-15

See Also

Other Utilities: add_text_img(), fa_icon_repeat(), fmt_pad_num(), fmt_pct_extra(), fmt_symbol_first(), generate_df(), gt_add_divider(), gt_badge(), gt_double_table(), gt_fa_column(), gt_fa_rank_change(), gt_fa_rating(), gt_fa_repeats(), gt_highlight_cols(), gt_highlight_rows(), gt_img_border(), gt_img_circle(), gt_img_multi_rows(), gt_img_rows(), gt_index(), gt_merge_stack_color(), gt_merge_stack(), gt_two_column_layout(), gtsave_extra(), img_header(), pad_fn(), tab_style_by_grp()

Examples

library(gt)
dupe_table <- head(mtcars) %>%
  dplyr::select(mpg, disp) %>%
  gt() %>%
  gt_duplicate_column(mpg, after = disp, append_text = "2")


gtExtras documentation built on Sept. 16, 2023, 1:08 a.m.