Created
May 18, 2017 18:39
-
-
Save gshotwell/52710761d33e241831b5f9e8f7925ae6 to your computer and use it in GitHub Desktop.
List destructuring in R
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
`%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