list.to.env | R Documentation |
Places named objects in a list into the working environment as individual variables. Can be particularly helpful when you want to call a function that produces a list of multiple return variables; this gives a way to access them all at once in the environment from which the function was called.
list.to.env(list)
list |
list, with named objects, each element will become a named variable in the current environment |
New variables will be added to the current environment. Use with care as any already existing with the same name will be overwritten.
base::list2env
list.to.env(list(myChar="a string", myNum=1234, myList=list("list within a list",c(1,2,3)))) print(myChar) print(myNum) print(myList) two.arg.return <- function(X) { return(list(Y=X+1,Z=X*10)) } result <- two.arg.return(11) # function returns list with 2 variables list.to.env(result) print(Y); print(Z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.