bdVector of the positions in
table of the elements of
x.
bdFrame,
bdFactor,
data.frame,
factor.
match(x, table, nomatch=NA, incomparables=F)
bdVector of items that are to be looked for in
table.
Missing values and and
Infs are allowed.
bdFrames, or lists
containing multiple vectors or
bdVectors.
x.
Missing values and
Infs are allowed.
x does not match any item in
table.
A useful alternative to
NA is
nomatch=0, which has the effect that
unmatched items are ignored when the matched indices are used in subscripts
(see the last example below).
bdVector of values that cannot be matched. Any value in
x that matches
a value in this vector or
bdVector is assigned the
nomatch value.
If
incomparables is
FALSE, all values can be matched.
bdVector of the same length as
x giving, for each element of
x, the
smallest
i such that
table[i] equals that element.
If no value in
table is equal to
x[j], then the
jth element of the
result is
nomatch.
Comparisons are done in the simplest mode that does not imply
an information loss.
For example, if both
x and
table are numeric, then comparisons
are numeric, but if either one is a character string, then
comparisons are of character strings.
If
x and
table
are data frames or
bdFrames, then
match(x, table)
indicates which
rows match.
Similarly for lists whose elements are vectors or
bdVectors of the same length;
the vectors or
bdVectors are treated as columns, and "rows" are matched.
primes <- c(2,3,5,7,11,13,17,19,23) match(data, primes) match(data, primes, incomp=2) # match to all primes but 2 state.abb[match(names, state.name)] # change names to abbrevs names[match(allnames, names, 0)] # those names also found in allnames