Skip to content
Prev 386946 / 398502 Next

Col names in a data frame

it looks to me that the names are cranked through make.names for
data frames case while that doesn't happen for matrices. Peeking
into the `colnames<-` code supports this idea, but that in turn
uses `names<-` which is a primitive and so defies further easy
peeking.

The data.frame function provides the check.names parameter to
switch this on / off, but for other classes this checking doesn't
seem to be provided.

Perhaps the idea behind this discrepancy is to enable the use of
the $ operator to access columns of the data frame, while that's
not possible for matrices anyway. (Personally, I don't find the
results of make.names that useful, though, and I tend to sanitise
them myself when working with data frames with unwieldy column
names).

Best regards, Jan
On Thu, Jan 21, 2021 at 03:58:44PM -0500, Bernard McGarvey wrote: