R change name of dataset with stored string

后端 未结 1 959
执笔经年
执笔经年 2021-01-29 02:38

I\'m creating lots of datasets with a loop and I need to make sure that all these different datasets are properly named and stored in the workspace. My question is the following

相关标签:
1条回答
  • 2021-01-29 02:47

    You can use list2env().

    list2env(AllDatasets, .GlobalEnv)
    

    Now e, f, g, h and i are available in your workspace (global environment in this case, you can specify a different environment in the second argument if you like).


    To assign a name from a string you can use assign(). E.g. in response to Marco's comment below:

    D <- data.frame(rnorm(1:10), rnorm(1:2))
    Name <- 'ThatOne'
    assign(Name, D)
    

    Or directly with a string:

    assign('ThatOne', D)
    
    0 讨论(0)
提交回复
热议问题