Skip to content
Prev 18050 / 63424 Next

drop() and "["(), and apply()

Dan Davison <davison at uchicago.edu> writes:
I think the logic is that if all dimnames are NULL, they are
discarded from the result. This probably predates the use of named
dimnames. Named NULL dimnames were not anticipated then, nor since...
I think this happens because vectors cannot have named dimnames.
Basically this happens because there's no obvious place to put it:
structure(1, .Names = "a")

i.e., the names are in a vector, not a list. This is a bit of a
bother (and forces the use of 1D arrays in some places, which in turn
confuses code that expects a vector), but implementing code that
carries an extra "name-name" attribute through all possible
calculations have been considered unattractive...

So, the function inside your apply()  construct returns a vector with
the right names, but loses the name of the names, at which point there
is no way to retrieve them.