Renaming the last column of a R dataFrame
Marginally less typing:
names(df)[ncol(df)] <- "space"
The following should do what you need:
colnames(df)[ncol(df)] <- "space"
You can use names()
instead:
names(df)[length(names(df))]<-"space"