Remove duplicate elements: Difference between revisions

+Stata
(+Stata)
Line 2,737:
return r;
}</lang>
 
=={{header|Stata}}==
===Duplicates in a dataset===
Stata can report duplicate lines, or remove them. See '''[http://www.stata.com/help.cgi?duplicates duplicates]''' in Stata help.
 
<lang stata>. clear all
. input x y
1 1
1 1
1 2
2 1
2 2
1 1
2 1
2 1
1 2
2 2
end
 
. duplicates drop x y, force
. list
 
+-------+
| x y |
|-------|
1. | 1 1 |
2. | 1 2 |
3. | 2 1 |
4. | 2 2 |
+-------+</lang>
 
===Mata===
 
The '''[http://www.stata.com/help.cgi?mf_uniqrows uniqrows]''' function removes duplicate rows from a matrix.
 
<lang stata>: a=1,1\1,1\1,2\2,1\2,2\1,1\2,1\2,1\1,2\2,2
 
: a
1 2
+---------+
1 | 1 1 |
2 | 1 1 |
3 | 1 2 |
4 | 2 1 |
5 | 2 2 |
6 | 1 1 |
7 | 2 1 |
8 | 2 1 |
9 | 1 2 |
10 | 2 2 |
+---------+
 
: uniqrows(a)
1 2
+---------+
1 | 1 1 |
2 | 1 2 |
3 | 2 1 |
4 | 2 2 |
+---------+</lang>
 
=={{header|Swift}}==
1,336

edits