help mata distinctrowsof()

Title

distinctrowsof() -- Distinct rows of matrix

Syntax

transmorphic matrix
distinctrowsof(transmorphic matrix X)

real colvector
_distinctrowsof(transmorphic matrix X)

transmorphic matrix
duplicaterowsof(transmorphic matrix X)

Description

distinctrowsof() selects the distinct rows of X; the function
is similar to Mata's uniqrows() but preserves the
sort order. For any duplicate rows, only the first row is selected.

_distinctrowsof() returns a column vector indicating the distinct
rows of X.

duplicaterowsof() returns all duplicate rows of X,
excluding the first occurrence of each row.

Remarks

: x
1 2 3
+
+
1 | 4 5 7 |
2 | 4 5 6 |
3 | 1 2 3 |
4 | 4 5 6 |
+
+

: distinctrowsof(x)
1 2 3
+
+
1 | 4 5 7 |
2 | 4 5 6 |
3 | 1 2 3 |
+
+

Conformability

distinctrowsof(X)
X: r1 x c1
result: r2 x c1, r2<=r1

_distinctrowsof(X)
X: r x c
result: r x 1

duplicaterowsof(X)
X: r1 x c1
result: r2 x c1, r2<=r1

Diagnostics

_distinctrowsof(), if X is scalar, returns 1. If
rows(X)==0, the function returns J(0, 1, 0); if
cols(X)==0, the function returns (1\ J(rows(X)-1, 1, 0)).

distinctrowsof() returns select(X,
_distinctrowsof(X)).

duplicaterowsof() returns select(X,
!_distinctrowsof(X)).

Source code

Distributed with the elabel package.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: mata, uniqrows()