| Unique {geometry} | R Documentation |
‘Unique’ returns a vector, data frame or array like 'x' but with duplicate elements removed.
Unique(X, rows.are.sets=FALSE)
X |
Numerical matrix. |
rows.are.sets |
If ‘TRUE’, rows are treated as sets - i.e., to define uniqueness,
the order of the rows does not matter. |
Matrix of the same number of columns as x, with the unique rows in x sorted according
to the columns of x. If rows.are.sets = TRUE the rows are also sorted.
Raoul Grasman
# `Unique' is faster than `unique' x = matrix(sample(1:(4*8),4*8),ncol=4) y = x[sample(1:nrow(x),3000,TRUE), ] gc(); system.time(unique(y)) gc(); system.time(Unique(y)) # z = Unique(y) x[matorder(x),] z[matorder(z),]