Unique

 

Description

This function takes a vector vs and returns the unique values. You can decide whether to sort the unique output values and how to reduce the duplicated values.

Syntax

 Dataset or StringArray  Unique(vector<string> vs[, int Sort, int Occurrence])

Parameters

vs

is the vector in which unique values are searched

Sort

[optional] integer that specifies whether to sort the output unique values:
  • sort = 1 (default), the output values are sorted in ascending order.
  • sort = 0, the values are outputted without sorting.
  • sort = 2, the output values are sorted in descending order.

Occurrence

[optional] integer that specifies how to reduce the duplicated values.
  • occurrence = 0 (default), the first duplicated value is remained.
  • occurrence = 1, the last duplicated value is remained.

Return

Returns a vector of the unique values in vs.

Examples

newbook;
col(A) = {1,10,15,8,2};
col(B) = unique(col(A));
StringArray sa;
sa = unique(col(a)); // assign unique values in col(a) to stringArray sa, sort in ascending order
range bb=col(b);
sa.CopyTo(bb); // copy contents of stringArray sa to col(b)