determining name of object loaded in R

后端 未结 3 1323
滥情空心
滥情空心 2021-02-02 16:55

Imagine you have an object foo that you saved as saved.file.rda as follows:

foo <- \'a\'
save(foo, file=\'saved.file.rda\')
<         


        
3条回答
  •  离开以前
    2021-02-02 17:42

    As you can read in ?load you can load data to specified environment. Then you could use get and ls to get what you want:

    tmp_env <- new.env()
    load('saved.file.rda', tmp_env)
    get(ls(tmp_env), envir=tmp_env) # it returns only first object in environment
    # [1] "a"
    

提交回复
热议问题