Extract Unique Rows
‘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 ‘ |
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.
‘Unique
’ is (under circumstances) much quicker than the
more generic base function ‘unique
’.
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),]
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.