Skip to contents

Convert snake_case-like column names to title-style labels, optionally preserving selected acronyms in uppercase. Title casing is minor-word aware (via snakecase::to_title_case()), so short connecting words such as "of", "to", "per", and "vs" stay lowercase (e.g. new_to_market becomes "New to Market").

Usage

rename_cols_for_display(data, all_caps = character())

Arguments

data

A data frame or tibble.

all_caps

A character vector of tokens to preserve in uppercase. Matching is case-insensitive and applied to whole words after formatting.

Value

A data frame with renamed columns.

Examples

data.frame(volume_py = 1, abc_units = 2) |>
  rename_cols_for_display(all_caps = c("PY", "ABC"))
#>   Volume PY ABC Units
#> 1         1         2