rename: Rename object names

Description Usage Arguments Examples

Description

Match and rename object names with new names.

Usage

1
2
3
rename(x, old, newn)

rename(x) <- value

Arguments

x

object to rename

old

names to match on

newn

new names, matched to 'old' by position

value

list with 'old' and 'new' containing the names to match on and names to be matched to, by position

Examples

1
2
3
4
5
6
7
x <- data.frame(foo = 1:3, bar = letters[1:3])
names(x) <- rename(x, "bar", "baz")
names(x)
# [1] "foo" "baz"
rename(x) <- list(old = "baz", new = "bar")
names(x)
# [1] "foo" "bar"

dslaw/r-stuff documentation built on May 15, 2019, 4:22 p.m.