Return elements of list as independent objects in global environment

前端 未结 3 2026
名媛妹妹
名媛妹妹 2020-11-27 06:31

I have a list, and would like to break the elements of the list into seperate objects in the global environment.

For example, I would like the list:



        
3条回答
  •  醉话见心
    2020-11-27 06:37

    There is special function for mapping list to environment:

    > obj <- list(a=1:5, b=2:10, c=-5:5)
    > ls()
    [1] "obj"
    > list2env(obj,globalenv())
    
    > ls()
    [1] "a"   "b"   "c"   "obj"
    

    P. S. It is my comment provided as an answer

提交回复
热议问题