How can I make a list of all dataframes that are in my global environment?

后端 未结 6 2309
不知归路
不知归路 2020-11-28 14:02

I am trying to use rbind on them. But I need a list of all the dataframes that are already in my global environment. How can I do it?

Code

6条回答
  •  北海茫月
    2020-11-28 14:20

    The ls function lists all things in your environment. The get function gets a variable with a given name. You can use the class function to get the class of a variable.

    If you put them all together, you can do this:

    ls()[sapply(ls(), function(x) class(get(x))) == 'data.frame']
    

    which will return a character vector of the data.frames in the current environment.

提交回复
热议问题