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

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04