I've done some research about this (here and here), but I haven't found what I actually want to achieve. The closest I've found to what I'm looking for is here, but the code doesn't seem to work or do what I desire. Besides, I found out that rbindlist
has been deprecated in favour of bind_rows
, but I haven't been able to use bind_rows
to achieve what I want.
I have a list of 30 dataframes each with the same number of rows and columns, as well as the same column datatypes (though each column could be either continuous and categorical). I want to merge them into a single dataframe of the same number of rows and columns, but with each cell as a mean/median/majority voting of the corresponding 30 cells from the list of dataframes, for continuous, integer, and categorical columns, respectively. Here's an example with three dataframes:
df 1:
A B C
2.3 5 3
12 3 1
0.4 13 2
df_2:
A B C
4.3 23 1
1 7 2
0.4 10 2
df_3:
A B C
1.3 3 3
2.2 4 2
12.4 10 1
And the resulting dataframe would be something like:
df_result:
A B C
2.63 5 3
5.06 4 2
4.4 10 2
Any directions to more appropriate ways of combining each of the datatypes would also be highly appreciated.