Julia: Detect and remove duplicate rows from array?

Viewed 10150

What is the best method of detecting and dropping duplicate rows from an array in Julia?

x = Integer.(round.(10 .* rand(1000,4)))

# In R I would apply the duplicated function.
x = x[duplicated(x),:]
3 Answers

Julia v1.4 and above you would need to type unique(a, dims=1) where a is your N by 2 Array

julia> a=[2 2 ; 2 2; 1 2; 3 1]
4×2 Array{Int64,2}:
 2  2
 2  2
 1  2
 3  1

julia> unique(a,dims=1)
3×2 Array{Int64,2}:
 2  2
 1  2
 3  1
Related