column_spanner_label: Prepend column spanner labels to data column labels

View source: R/formatting.R

column_spanner_labelR Documentation

Prepend column spanner labels to data column labels

Description

Prepend column spanner labels to data column labels

Usage

column_spanner_label(data, label, ..., relocate = TRUE)

Arguments

data

data.frame or tibble

label

character of column spanner

...

columns (i.e., one or more tidyselect functions and/or a vector of quoted or unquoted variable names)

relocate

relocate columns with same spanner label to be adjacent

Value

data.frame or tibble

Examples

d <- data.frame(y = 1:3, x1 = 2:4, x2 = 3:5)

# Unquoted variable names
column_spanner_label(d, "Label", c(x1, x2))
# Character values (quoted variable names)
column_spanner_label(d, "Label", c("x1", "x2"))
# Tidyselect function (e.g., starts_with, ends_with, contains)
column_spanner_label(d, "Label", dplyr::starts_with("x"))
# Tidyselect range
column_spanner_label(d, "Label", x1:x2)
# Selected variables are relocated after the first selected variable
column_spanner_label(d, "Label", c(x2, y))

apa7 documentation built on May 26, 2026, 5:07 p.m.