Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gshotwell/52710761d33e241831b5f9e8f7925ae6 to your computer and use it in GitHub Desktop.
Save gshotwell/52710761d33e241831b5f9e8f7925ae6 to your computer and use it in GitHub Desktop.
List destructuring in R
`%d%` <- function(vars, list){
for(i in vars){
assign(i, list[[i]], envir = .GlobalEnv)
}
}
c("mpg", "cyl") %d% mtcars
test_list = list(cars = mtcars,
numbers = 1:500,
char = c("tom", "joey", "samatha"),
sublist = list(test = 1:50, data = letters))
c("cars", "sublist") %d% test_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment