I have the following binary dataframe
A B C D 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1
I would like to create a list with all the column combinations and count the rows with '1' that are in common.
More precisely something like that:
A B 1 A C 1 A D 0 B A 1 B C 3 B D 1 C A 1 C B 3 C D 2 D A 0 D B 1 D C 2
But I'm struggling to think of a way to do that in R. I would appreciate any hint towards the right direction
Alternatively, a 'correlation'-like matrix would work for me. For example:
A B C D A 0 1 1 0 B 1 0 3 1 C 1 3 0 2 D 0 1 2 0
https://stackoverflow.com/questions/66078607/convert-a-binary-dataframe-to-a-grouped-long-list-of-combinations February 06, 2021 at 11:33PM
没有评论:
发表评论