dat <- data.frame(a = c(3, 1, 6),
b = c(4, 2, 5),
c = c(7, 3, 1))
# Example 1: Rename variable b in the data frame 'dat' to y
df.rename(dat, from = "b", to = "y")
# Example 2: Rename variable a, b, and c in the data frame 'dat' to x, y, and z
df.rename(dat, from = c("a", "b", "c"), to = c("x", "y", "z"))
Run the code above in your browser using DataLab