Skip to content
Prev 377406 / 398502 Next

which element is duplicated?

You also asked about doing this for the rows of a matrix.  unique() give
the unique rows but match operates on a per element, not per row,
basis.  You can use split, which operates on rows of a matrix, to help.
A B
i  5 2
ii 5 3
iv 4 2
[1] 1 1 1 3 3 3 4 5 4 4 4 4
[1] 1 2 1 3 3 3


For data.frames unique works on rows but match works on columns, and
converting
to a list of rows does not quite work, because unique looks at the row
names.  A
modification of asRoiws works around that:
A B
i  5 2
ii 5 3
iv 4 2
[1] NA NA
[1] 1 2 1 3 3 3


Is this the sort of issue that Hadley's vectors package is addressing?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Nov 13, 2018 at 2:15 AM, Duncan Murdoch <murdoch.duncan at gmail.com>
wrote: