View source: R/DummyDuplicated.R
DummyDuplicated | R Documentation |
The algorithm is based on crossprod(x)
or crossprod(x, u)
where u
is a vector of random numbers
DummyDuplicated(x, idx = FALSE, rows = FALSE, rnd = FALSE)
x |
A matrix |
idx |
Indices returned when TRUE |
rows |
Duplicated rows instead when TRUE |
rnd |
Algorithm based on cross product with random numbers when TRUE (dummy matrix not required) |
The efficiency of the default algorithm depends on the sparsity of crossprod(x)
.
The random values are generated locally within the function without affecting the random value stream in R.
Logical vectors specifying duplicated columns or vector of indices (first match)
Øyvind Langsrud
x <- cbind(1, rbind(diag(2), diag(2)), diag(4)[, 1:2])
z <- Matrix(x[c(1:4, 2:3), c(1, 2, 1:5, 5, 2)])
DummyDuplicated(z)
which(DummyDuplicated(z, rows = TRUE))
# Four ways to obtain the same result
DummyDuplicated(z, idx = TRUE)
DummyDuplicated(z, idx = TRUE, rnd = TRUE)
DummyDuplicated(t(z), idx = TRUE, rows = TRUE)
DummyDuplicated(t(z), idx = TRUE, rows = TRUE, rnd = TRUE)
# The unique values in four ways
which(!DummyDuplicated(z), )
which(!DummyDuplicated(z, rnd = TRUE))
which(!DummyDuplicated(t(z), rows = TRUE))
which(!DummyDuplicated(t(z), rows = TRUE, rnd = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.