How to make a list of many data frames without entering their names in r?

I worked on several hundred files that I automatically uploaded to the workspace as separate data frames (for example, I have 500 data frames in my workspace).

I would like to create a list consisting of all dataframes / objects in the workspace and apply a function to all of them. Of course, I could enter all the objects manually, but this is not very effective for hundreds or thousands of frames. I was wondering if there is a way to use function output ls(), for example:

ls()
[1] "a"    "b"    "c"     "d"                      
[5] "e"    "f"    "g"     "h"       
[9] "i"    "j"    "k"     "l"    
[13] "m"    "n"    "o"     "p"          
...

Unfortunately, when I extract from the output ls(), I only end up with the character character of the strings, not the list of dataframes.

I would be grateful for your ideas. Thank.

EDITED: r , , .

+4
3

, data.frame ls, Filter class. , , R :

> df1=data.frame(col=1:10)
> df14=data.frame(col=1:10)
> rr=3

data.frame:

dfnames=Filter(function(x) class(get(x))=='data.frame', ls(env=globalenv()))
#>dfnames
#[1] "df1"  "df14"

data.frame:

> lapply(dfnames, get)
[[1]]
   col
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
10  10

[[2]]
   col
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
10  10

, , .

+2

Hi :

m1 = mtcars
m2 = mtcars
m3 = 1:10
m4 = "blabla"
df_list <- mget(ls()[sapply(ls(), function(x) is.data.frame(get(x)))])

+1

data.frames - , , :

my_list=sapply(ls(),get)

, , grep().

0
source

All Articles