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

 vector<string> 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.

Example

newbook;
col(A) = {1,10,15,8,2};
col(B) = unique(col(A));