set_names_match: Set Names in an Object that Match Lookup table

Description Usage Arguments Value Examples

View source: R/names.R

Description

Set names of object by matching object's old names to names of lookup table. This will ensure that object's names will always named correctly. This function also wraps rlang::set_names().

Usage

1
set_names_match(x, lookup = x, invert = FALSE, quiet = FALSE, ...)

Arguments

x

Vector to name.

lookup

Lookup vector: the names of lookup must corresponding to "old names" of x and the values of lookup will be set as "new names" of x

invert

Logical: If TRUE, invert names and values of lookup.

quiet

Logical: If FALSE, the message of non-matching names of x will be displayed.

...

passed to rlang:set_names()

Value

x with new names

Examples

1
2
3
4
set_names_match(iris, c("Sepal.Length" = "SL",
                        "Sepal.Width" = "SW",
                        "Petal.Length" = "PL")
               )

Lightbridge-AI/lbr documentation built on Dec. 27, 2021, 8:09 p.m.