matchval: Maps values between vectors.

Description Usage Arguments Details Value Factors TODO

Description

The positions of x in from are used to retrieve values from to.

Usage

1
matchval(query, from, to, nomatch = NA, .warn_nomatch = FALSE)

Arguments

query

The source vector of values.

from

The 'key' vector against which query is matched.

to

The 'return' vector from which values are returned based on position.

nomatch

The returned value for cases where query is unmatched in from.

.warn_nomatch

Warn in cases of no match? (Without a warning, one cannot distinguish the unmatched case vs the case where to contains the value nomatch.

Details

Given an entry in query find the matching index in from. Then retrieve the value at that index in to. If an entry in query cannot be found in from, the corresponding returned value is nomatch. Take note that if to contains any nomatch values, presence of nomatch in the returnd value doesn't indicate that some query was missing in from, but one can use the .warn_nomatch case to disambiguate between these two cases.

Value

Values in to corresponding to the indices returned by match(query,from), or nomatch.

Factors

What if query is a factor? To achieve factor recoding, use forcats::fct_recode instead.

TODO


mmuurr/zzz documentation built on May 14, 2019, 12:46 p.m.