how to rename one dataframe in a list



How to rename b to newname only? I tries names(lst[2])="newname" and it doesn’t work.

lst <- list(a="one", b="two", c=c(1:3))


Extract the names, then subset with index and assign

names(lst)[2] <- "newname"

Though, we can extract the names (getter) with

[1] "b"

The assignment (setter –names<-) should be on the whole object and not on the subset of the object

Answered By – akrun

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More