Skip to main content

FindDuplicates

FindDuplicates [flags ] srcWave

The FindDuplicates operation identifies duplicate values in a wave and optionally creates various output waves. srcWave can be either numeric (real or complex) or text.

When srcWave is numeric, the /DN, /INDX, /RN and /SN flags create output waves as described below. If you omit all of these flags then FindDuplicates uses the /INDX flag by default.

When srcWave is text, the /DT, /INDX, /RT and /ST flags create output waves as described below. If you omit all of these flags then FindDuplicates uses the /INDX flag by default.

The FindDuplicates operation was added in Igor Pro 7.00.

Flags

/FREECreates all output waves as a free waves. The /FREE flag was added in Igor Pro 8.00.
/FREE is permitted in user-defined functions only. If you use /FREE then all output wave parameters must be simple names, not paths or $ expressions.
See Free Waves for details on free waves.
/INDX=indexWaveCreates a numeric output wave containing the index of each encountered duplicate. The index is the point number in srcWave where a duplicate value was encountered. This flag applies to both numeric and text inputs.
/INDX is the default behavior if no flags specifying the output wave are provided (/DN, /RN, /SN, or /INDX for numeric waves; /DT, /RT, /ST, or /INDX for text waves). In this case, W_DuplicateIndex is the default output wave.
/ZDo not report any errors.

Flags for Numeric Source Wave

/DN=dupsWaveCreates a numeric output wave that contains the duplicates.
/RN=dupsRemovedWave
Creates a numeric output wave that contains the source data with all duplicates removed.
/SN=replacementCreates a numeric output wave with all duplicates replaced with replacement. replacement can be any numeric value including NaN, INF, and complex numbers.
The output wave is W_ReplacedDuplicates in the current data folder unless you specify a different output wave using the /SNDS flag.
/SNDS=dupsReplacedWave
Specifies the output wave generated by /SN. If you omit /SNDS then the output wave created by /SN is W_ReplacedDuplicates in the current data folder. /SNDS without /SN has no effect.
/TOL=toleranceSpecifies the tolerance value for single-precision and double-precision numeric source waves.
Two values are considered duplicates if
abs(value1-value2) <= tolerance
By default tolerance is zero.
/UN=uniqueNumbersWave
Creates a numeric output wave that contains the unique numbers in srcWave sorted from small to large. When srcWave contains NaN entries they are sorted as the last point in uniqueNumbersWave.
/UN is incompatible with /RN which maintains the order of entries in srcWave.
The /UN flag was added in Igor Pro 9.00.
/UNC=uniqueCountsCreates a numeric output wave that contains the count of each entry in the uniqueNumbersWave created by the /UN flag.
The /UNC flag was added in Igor Pro 9.00.

Flags for Text Source Wave

/CIPerforms case-insensitive text comparisons on ASCII characters only. For example, "A" and "a" are considered duplicates.
The /CI flag was added in Igor Pro 9.00.
/DT=dupsWaveCreates a text output wave that contains the duplicates.
/LOCPerforms locale-aware text comparisons which take case into account for both ASCII and non-ASCII characters. For example, the non-ASCII characters "Å" and "å" are considered duplicates as well as the ASCII characters "A" and "a".
/LOC is ignored unless you also include /CI.
The /LOC flag was added in Igor Pro 9.00.
/RT=dupsRemovedWave
Creates a text output wave that contains the source data with all duplicates removed.
/ST=replacementStrCreates a text output wave with all duplicates replaced with replacementStr. replacementStr can be any text value including "".
The output wave is T_ReplacedDuplicates in the current data folder unless you specify a different output wave using the /STDS flag.
/STDS=dupsReplacedWave
Specifies the output wave generated by /ST. If you omit /STDS then the output wave created by /ST is T_ReplacedDuplicates in the current data folder. /STDS without /ST has no effect.

Details

FindDuplicates scans srcWave and identifies duplicate values. The first instance of any value is not considered a duplicate. Duplicates are either identical, as is the case with integer or text waves, or values that are within a specified tolerance in the case of single-precision or double-precision numeric waves.

Text comparison is case-sensitive unless you use /CI or /CI/LOC.

The operation creates wave references for the waves specified by the various flags above. See Automatic Creation of Wave References for details.

Example

Function DemoFindDuplicates(mode)
int mode // 0=case sensitive; 1=/CI; 2=/CI/LOC

Make/O/T sourceText={"A","a", "Å","å", "B","b"}
switch(mode)
case 0: // Case sensitive
// Returns {"A","a","Å","å","B","b"}
FindDuplicates/FREE/RT=output sourceText
break
case 1: // Case insensitive for ASCII only
// Returns {"A","Å","å","B"}
FindDuplicates/FREE/RT=output/CI sourceText
break
case 2: // Case insensitive, locale aware
// Returns {"A","Å","B"}
FindDuplicates/FREE/RT=output/CI/LOC sourceText
break
endswitch

Print sourceText
Print output
End

See Also

FindLevels, FindValue, Sort, TextHistogram