I have three data frames, df1
, df2
and df3
consisting of 42, 103 and 414 columns respectively.
I want to see which columns all three data frames have in common / share so that I can establish how to join them.
I am aware of intersect()
being able to determine whether two objects share any columns, but as this is limited two only two objects, a good workaround is to use Reduce(intersect, list(a, b, c))
in order to be able to compare more than two.
As such, when I try this, I receive an error regarding the number of columns:
> Reduce(intersect, list(colnames(df1), colnames(df2), colnames(df3)))
Error: not compatible:
- different number of columns: 42 vs 103
Is there a workaround or alternative approach to this problem?
I have come across a number of similar questions, but nothing that seems to match my problem more closely, so I decided to pose this question.