Created
January 25, 2019 20:31
-
-
Save stufield/63cab2417b08d797e8e83abbede89a34 to your computer and use it in GitHub Desktop.
dplyr::rename() works for data frames only, this works for list renaming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo <- list(a = 1:5, b = letters, c = data.frame(set = 1:4)) | |
key <- c(b = "super", a = "awesome", c = "wicked") | |
nm <- . %>% purrr::map_chr(~ key[[.x]]) | |
foo %>% purrr::set_names(nm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment