OneBite.Dev - Coding blog in a bite size

remove duplicates from an array in R

Code snippet on how to remove duplicates from an array in R

# Sample Code to remove duplicates from an array in R

unique.array <- unique(array) # array is an array variable
``

This code creates a new variable called unique.array and stores in it a sorted list of the unique elements from the array variable. The unique function looks at the array and creates a new array that only includes one of each element. The sorted list is created by the order of the elements in the original array.
r