修订版 | 4055c222ba54944d84fb2e1ad56e47fceb426041 (tree) |
---|---|
时间 | 2022-04-21 04:21:27 |
作者 | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I added a function to recode many values at the same time.
@@ -6447,3 +6447,16 @@ | ||
6447 | 6447 | return(links) |
6448 | 6448 | } |
6449 | 6449 | |
6450 | + | |
6451 | + | |
6452 | +## See discussion at https://github.com/tidyverse/dplyr/issues/3218 | |
6453 | + | |
6454 | + | |
6455 | +recode_many <- function(x, old_names, new_names){ | |
6456 | + | |
6457 | + name_lookup <- set_names(new_names, old_names) %>% as.list | |
6458 | + | |
6459 | + res <- recode(x, !!!name_lookup) | |
6460 | + return(res) | |
6461 | + | |
6462 | +} |