Set intersection from a list containing data frames
I have a list where each item in the list is a data frame.
> df.list[[1]]
Change Diff VarName
1 10.433354 5.311973e-02 a
2 4.587958 1.517604e-02 b
3 4.566829 1.082679e-02 c
4 4.464458 1.345807e-02 d
5 4.146909 7.758011e-03 e
6 4.141556 1.416043e-02 f
> df.list[[2]]
Change Diff VarName
1 12.443354 5.311973e-02 j
2 3.587958 1.517604e-02 k
3 4.566829 1.082679e-02 a
4 4.464458 1.345807e-02 b
5 3.146909 7.758011e-03 d
6 2.141556 1.416043e-02 e
The length of my list is 10, where there are 10 data frames. each data frame has 30 elements. I want intersect
each top 25 dataframes with a different one and finally get the most common items in all dataframes.
Here's what I've done so far:
df1 <- df.list[[1]]$VarName
df2 <- df.list[[2]]$VarName
df3 <- df.list[[3]]$VarName
df4 <- df.list[[4]]$VarName
intersect(intersect(intersect(df1,df2), df3), df4)
Off to do it using dplyr
any other tool.
+3
source to share