-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A proposed function to port plyr::mapvalues() to dplyr #7027
Comments
Eventually we will add fv <- sample(LETTERS[1:5], size = 1e4, T)
dplyr:::vec_case_match(
needles = fv,
haystacks = as.list(LETTERS[1:4]),
values = as.list(letters[1:4])
) See also r-lib/vctrs#1622. Going to close this in favor of that, since it is the ultimate solution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A proposed function to adapt a typical
plyr::mapvalues
use case to dplyrThe advent of
case_match
has brought many of the recoding functionality ofplyr::mapvalues
intodplyr
.However, a use case remains where there is a long vector of
from
values, and a long vector ofto
values, andplyr::mapvalues
lets you concisely express this in a way thatcase_when()
andcase_match()
don't replicate.My (primitive! risible!) attempt at a working function (I understand it would have to be adapted to match
tidyverse
style if deemed a candidate for inclusionIt seems reasonably performant
should return
The text was updated successfully, but these errors were encountered: