Skip to contents

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

Examples

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