Skip to content
Prev 258776 / 398502 Next

Change the names of a dataframe

In the first case you create a new data frame consisting of the 2nd column of the original, then change the name of the only column in that new data frame, then since nothing is done with that data frame it gets thrown away.  So it is not that nothing happened, but just that nothing useful happened.  The original data frame was never changed, just a copy of it.

The second method access the names, then changes the 2nd name and therefore changes the actual data frame of interest.