match.split {wordspace} | R Documentation |
Find Parallel Matches for Values in Groups (wordspace)
Description
Given a set of values and a grouped vector x
, find parallel matches of each value in the different groups and return their positions in the original vector x
. If there are multiple matches of the same value in a group, only the position of the first match is returned.
Usage
match.split(x, f, values=NULL, groups=NULL, nomatch=NA_integer_)
Arguments
x |
vector to be divided into groups and matched against |
f |
a factor that defines the grouping (or a vector that can be converted to a factor) |
values |
values to be matched in |
groups |
a character vector listing the set of groups to be formed. Defaults to the levels of |
nomatch |
the value to be returned in cases where no match is found (coerced to an integer) |
Value
An integer matrix with one row for each value (in values
) and one column for each group (in groups
), specifying the index in x
of the first match of a value within the respective group. If not match is found for a given combination of value and group, nomatch
is inserted (defaults to NA
).
Author(s)
Stephanie Evert (https://purl.org/stephanie.evert)