unique

Basics

unique is a function that returns a version of an array-like object without duplicate values/rows.


Examples

Return a vector of all unique values in the object vec.

Click to see solution
vec <- c(1, 2, 3, 3, 3, 4, 5, 5, 6)
unique(vec)
[1] 1 2 3 4 5 6