Skip to content

Instantly share code, notes, and snippets.

@stufield
Created January 25, 2019 20:31
Show Gist options
  • Save stufield/63cab2417b08d797e8e83abbede89a34 to your computer and use it in GitHub Desktop.
Save stufield/63cab2417b08d797e8e83abbede89a34 to your computer and use it in GitHub Desktop.
dplyr::rename() works for data frames only, this works for list renaming
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