ys_recode: Recode column names in a vector

View source: R/ys-tidy.R

ys_recodeR Documentation

Recode column names in a vector

Description

Use a yspec object to convert a vector of column names to the short name with the unit optionally appended.

Usage

ys_recode(col, spec, ..., unit = FALSE)

Arguments

col

A character vector of names in spec.

spec

A yspec object.

...

Passed to ys_get_short() (when unit is FALSE) or ys_get_short_unit() (when unit is TRUE); specifically note that title_case and short_max can be passed along.

unit

Logical indicating if the unit should be appended to the short name.

Examples

spec <- ys_help$spec()

x <- c("WT", "BAR", "SCR", "TIME", "FOO")

ys_recode(x, spec)

ys_recode(x, ys_select(spec, -TIME), unit = TRUE, title_case = TRUE)


metrumresearchgroup/yspec documentation built on Dec. 22, 2024, 1:37 a.m.