Name the first unnamed automated generated column?


is it possible to name the first unnamed automated generated column in a data.frame? as you can see with the following code, i replaced the very first automated generated column with my first column.

if not, how can i access the data there? thank you

df<-data.frame(column1=letters[1:5], column2=1:5, column3=LETTERS[1:5])
rownames(df) <- df[,1]
df[,1] <- NULL


These are the row names of the data frame. They aren’t actually a column at all: they are a vector of values stored separately as an attribute of the object. They also have to follow specific rules (there can’t be any duplicated values) and — fair warning — they do not always behave the way people expect. As an attribute, there is no way to give them a name (other than their built-in name of row.names).

Usually when people want to name the row names, it’s because they are working with a data frame that already has meaningful row names. The usual advice is to convert the row names into a proper column. But you seem to be trying to move data from a proper column into the row names, so I think it will help if you can explain more of the bigger picture of what you’re trying to do?

More info on row names...

The base documentation for row names in data frames:

A deep dive into the (sometimes unexpected) behavior of row names in data frames:

A briefer argument against using row names in data frames:

A useful explanation of the difference between the row.names() and rownames() functions:


thank you for your reply, which already answered my question. i solved the problem with you're advice to convert the row names into a proper column, then i could give them the name i had to.