Skip to content
Prev 35222 / 63421 Next

extraction of sub-matrix by name

This is documented behavior. From ?"[.data.frame":

Both ?[? and ?[[? extraction methods partially match row
names. By default neither partially match column names, but
?[[? will unless ?exact=TRUE?. If you want to do exact
matching on row names use ?match? as in the examples.

In the history of S, S-PLUS and R partial matching for subscripts and 
indices has been used in many places, but over time it has been removed 
from some. Some methods for "[[" have an "exact" argument that allows 
specification of whether you want exact or prefix matches. However, as 
the docs indicate, this doesn't apply to "[" for rownames in data 
frames. At this point, the behavior is unlikely to change -- it risks 
breaking too much old code (that's just my opinion based on observation 
of the evolution of R -- I have no control over that evolution). Follow 
the suggestion in the help for [.data.frame to get exact matching.

-- Tony Plate
Yurii Aulchenko wrote: