If A
and B
are tables (or datasets) having the same the same columns (and in the same order), then an expression like ismember(A(:, somecols), B(:, somecols))
will produce a boolean array suitable for indexing A
with, as in
A(ismember(A(:, somecols), B(:, somecols)), :)
The line above evaluates to a table
(or dataset
, depending on the class of A
) consisting of those rows of A
that match some row of B
at the columns specified in somecols
.
But now suppose that B
has exactly one row. More realistically, suppose that the criterion for selecting rows from A
is simply to match this one single row of B
, say the first one.
One could do this:
A(ismember(A(:, somecols), B(1, somecols)), :)
The main quibble I have with this is that it is not "semantically clear", because ismember
is being used, in effect, to test for equality.
It would be semantically clearer if one could write
A(isequal(A(:, somecols), B(1, somecols)), :)
but this does line not produce the desired results. (Specifically, it returns no matches even when A(:, ...)
contains rows matching B(1, ...)
.)
My question is, what is the predicate that will correctly produce the logical vector corresponding to the question "does this row of A
match this reference row at somecols
"?