I'm looking to rename columns in my data.frame from another list. Here's my example :
mylist <- list(
var1 = "toto",
var2 = "titi"
)
mytable <- data.frame(
var1 = letters[1:3],
var2 = letters[4:6],
var6 = letters[7:9]
)
I tried that but without success :
names(mytable) <- sapply(names(mytable), function(x) mylist$x)
Expected result :
names(mytable) <- c("toto","titi","var6")