Match Items against a Table - Generic function

DESCRIPTION:

Returns a vector or bdVector of the positions in table of the elements of x.

This function is a generic; methods can be written to handle specific classes of data. Classes which already have methods for this function include:
bdFrame, bdFactor, data.frame, factor.

USAGE:

match(x, table, nomatch=NA, incomparables=F) 

REQUIRED ARGUMENTS:

x
Vector or bdVector of items that are to be looked for in table. Missing values and and Infs are allowed.
Some methods handle other objects, such as data frames, bdFrames, or lists containing multiple vectors or bdVectors.
table
the possible values in x. Missing values and Infs are allowed.

OPTIONAL ARGUMENTS:

nomatch
the value to be returned when an item in 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).
incomparables
a vector or 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.

VALUE:

integer vector or 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.

DETAILS:

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.

SEE ALSO:

, , , , , , , , , .

EXAMPLES:

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