matMatch | R Documentation |
Wrapper for matching a matrix against another, by rows or columns.
matMatch(x, mat, rows = TRUE, useMatch = FALSE, ...)
x |
matrix with the values to be matched. |
mat |
matrix with the values to be matched against. |
rows |
whether the match should be done by rows ( |
useMatch |
whether to rely on |
... |
further parameters passed to |
An integer vector of length nrow(x)
(or ncol(x)
)
giving the row (or col) position in table of the first match, if there is
a match.
# By rows
A <- rbind(5:6, repRow(1:2, 3), 3:4)
B <- unique(A)
ind <- matMatch(x = A, mat = B)
A
B[ind, ]
# By columns
A <- cbind(5:6, repCol(1:2, 3), 3:4)
B <- t(unique(t(A)))
ind <- matMatch(x = A, mat = B, rows = FALSE)
A
B[, ind]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.