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.
match.split(x, f, values=NULL, groups=NULL, nomatch=NA_integer_)
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
).
vector to be divided into groups and matched against
a factor that defines the grouping (or a vector that can be converted to a factor)
values to be matched in x
.
Defaults to values that occur in all groups of x
as determined by f
and groups
a character vector listing the set of groups to be formed. Defaults to the levels of f
and should be a subset of these levels if given explicitly
the value to be returned in cases where no match is found (coerced to an integer)
Stephanie Evert (https://purl.org/stephanie.evert)