Am 16.04.2026 um 10:45 schrieb Riccardo (Jack) Lucchetti:
There is a more general point that IMO is worth considering. Suppose
we're slicing a matrix with row/column names (via traditional methods
or via this cool new feature). Should names be carried over to the
resulting objects? To be more explicit (quoting from above):
<hansl>
set seed 765545431
matrix M = mnormal(4,3)
cnameset(M, "one two three")
matrix c = M[,"two"]
</hansl>
should the "c" vector be endowed with the column name "two" too? My
spontaneous reaction would be "no" (on the grounds of efficiency), but
others may disagree.
I think the question of whether names are preserved after
indexing/slicing should be separated from the way the slicing is done. I
thought that standard (numeric) indexing would preserve the names, but I
just checked and it's actually not the case. Maybe because of efficiency
as you say. But in any case I think name-indexing should not introduce a
special case for this behavior.
thanks
sven