Skip to content
Prev 24455 / 63424 Next

Non-unique column names in data frames

On Sun, 1 Apr 2007, John Fox wrote:

            
??  matrices and data frames are different, but rownames() and row.names() 
do the same on each class.
as does rownames().
It's part of the definition of a data frame, from long ago (White Book 
p.60).  Think of the row names as a 'primary key' in the sense of a 
DBMS/SQL.

Why the names are not also required to be non-empty and unique 
is something for the designer (and John Chambers has not (yet) replied), 
but it is clearly deliberate as data.frame(check.names=FALSE) is allowed.
One possible issue is that there are many ways to set names of a data 
frame, e.g. DF$name <- value can add a column, and checking them all could 
be tedious.  OTOH, setting row names is centralized (it is done inside
attr<-()).