Unique values

It is often useful to determine the unique values present in a vector or an array.

This can be achieved by using the unique() function and passing the index of the data over which you want to find the unique values.

In the example below we first create a vector of integers then pass this vector into the unique function by calling the variable name.


Input:
x <- c(2,3,7,4,2,7,8,9,2)
y <- unique(x)
print(y)

Output:
[1] 2 3 7 4 8 9