mapnames: Map Names Flexibly in a Data.Frame or Vector A wrapper for...

Description Usage Arguments Value Examples

Description

Map Names Flexibly in a Data.Frame or Vector A wrapper for 'mapvalues' (which only supports vectors, not data frames), with the same mapping rules. 'from' and 'to' must have equal lengths.

Usage

1
mapnames(df, from, to)

Arguments

df

: a data frame whose names need changed

from

: a character vector with old col names.

to

: a character vector with new col names.

Value

df : a dataframe with the same values as input, but possibly replaced colnames

Examples

1
2
3
4
5
6
7
8
# DF Operand
mapnames(mtcars,
         from = c("cyl", "hp"),
         to   = c("cylinders", "horsepower"))
# Nmd Vector Operand
mapnames(mtcars$cyl %>% set_names(),
         from = c(4, 6),
         to   = c("four", "six"))

mbadge/MyUtilsR documentation built on May 27, 2019, 1:08 p.m.