From jfox at mcmaster.ca  Sun Apr  1 15:57:42 2007
From: jfox at mcmaster.ca (John Fox)
Date: Sun, 1 Apr 2007 09:57:42 -0400
Subject: [Rd] Non-unique column names in data frames
Message-ID: <20070401135743.EZTQ1612.tomts36-srv.bellnexxia.net@JohnDesktop8300>

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?

Regards,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox



[Rd] Non-unique column names in data frames
John Fox