Store and get variables by their names from a list
a1 <- "10"
a2 <- NULL
a3 <- 1:10
# To store variables in a named list
px <- mget(x=c("a1", "a2", "a3"))
# To extract variables from a named list
np <- names(px)
invisible(lapply(seq_along(np), FUN = function(x) assign(np[x], px[[x]], envir = .GlobalEnv)))
Commentaires
Enregistrer un commentaire