Suppose I have a named list x
:
x <- list(a = 1, b = 2)
How can I load the content of x
into the global environment so that I can access a
and b
from the global environment?:
a
# [1] 1
b
# [2] 2
(why I do this: in reality, the x
is derived from a .mat
file produced by matlab. It's more like an .Rdata
file)
We can use list2env
list2env(x, .GlobalEnv)
a
#[1] 1
b
#[1] 2