ys_rename: Rename items in a yspec object or data.frame

View source: R/ys-tidy.R

ys_renameR Documentation

Rename items in a yspec object or data.frame

Description

What gets renamed depends on the first argument: either yspec object or data.frame. When renaming yspec object, use new = old syntax. When renaming columns in data.frame, pass old names only in tidy select syntax; the new names come from calls to ys_get_short() or ys_get_short_unit().

Usage

ys_rename(.x, ...)

## S3 method for class 'yspec'
ys_rename(.x, ...)

## S3 method for class 'data.frame'
ys_rename(.x, .spec, ..., .title_case = TRUE, .short_max = Inf, .unit = FALSE)

Arguments

.x

A yspec object or data.frame to rename.

...

For the yspec method, pass tidy rename syntax (new = old); for the data.frame method, pass tidy select syntax to select columns to rename (new names come from the spec); see examples.

.spec

A yspec object.

.title_case

Passed to ys_get_short() or ys_get_short_unit().

.short_max

Passed to ys_get_short() or ys_get_short_unit().

.unit

Logical indicating if the unit should be appended to the short rename value.

Value

A yspec object or data.frame with renamed columns, depending on what was passed as .x.

See Also

ys_join(), ys_filter(), ys_select()

Examples

spec <- ys_help$spec()

ans <- ys_rename(spec, TIME = TAFD, RENAL = RF)

tail(ans)

data <- ys_help$data()

ys_rename(data, spec, AGE:HT)


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