Description Usage Arguments Details Value Author(s) See Also Examples
Multiple matching between two vectors. Different from R-native match
function, where only one match is returned even if there are multiple
matches, mmatch
returns all of them.
1 | mmatch(x, table, nomatch = NA_integer_)
|
x |
vector or |
table |
vector or |
nomatch |
the value to be returned in case when no match is found. |
Multiple matches can be useful in many cases, and there is no native R
function for this purpose. User can write their own functions combining
lapplying
with match
or %in%
, our experience however
shows that such non-vectorized function can be extremely slow, especially
when the x
or table
vector gets longer.
mmatch
delegates the multiple-matching task to a C-level function,
which is optimized for speed. Internal benchmarking shows improvement of
hundred fold, namely using mmatching
costs about 1/100 of the time
used by R-implementation.
A list of the same length as the input x
vector. Each list
item contains the matching indices (similar to match
).
Jitao David Zhang <jitao_david.zhang@roche.com>, C-code was adapted from the program written by Roland Schmucki.
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.