[Rd] Non-unique column names in data frames

John Fox jfox at mcmaster.ca
Sun Apr 1 15:57:42 CEST 2007

Dear r-devel members,

It's just been brought to my attention that R permits non-unique column
names in data frames -- e.g., via assignment to names() or colnames(). This
behaviour is consistent with the help files (as I discovered), but it's not
consistent with the behaviour of rownames() and row.names(). For example,

	row.names(airquality) <- rep("a", nrow(airquality)) 

generates an error, but 

	names(airquality) <- rep("a", ncol(airquality))

or even 

	names(airquality) <- rep("", ncol(airquality))

do not.

I figure that there must be some rationale for this difference, but I can't
think of what it might be. Any thoughts?


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4

More information about the R-devel mailing list