Change the variable names of a data.frame

change_names(x, from, to, must_have=TRUE)

Arguments

x

data.frame

from

column names to be changed

to

what column names need to be changed to

must_have

logical. Give an error of one of the names is not present or duplicated

Value

data.frame

Examples

d <- data.frame(x=1:3, y=3:5, z=10:12)
change_names(d, c("y", "z"), c("B", "C"))
#>   x B  C
#> 1 1 3 10
#> 2 2 4 11
#> 3 3 5 12