How to load the contents of a named list into a global environment?

Suppose I have a named list x:

x <- list(a = 1, b = 2)

How to upload content xto a global environment so that I can access aand bfrom a global environment ?:

a
# [1] 1
b
# [2] 2

(why am I doing this: actually, xderived from a file .matcreated by matlab. This is more like a file .Rdata)

+4
source share
1 answer

We can use list2env

list2env(x, .GlobalEnv)
a
#[1] 1
b
#[1] 2
+4
source

Source: https://habr.com/ru/post/1693298/


All Articles