I am working on data that contains more than 300 categorical features that I have factored into 0s and 1s. Now, i need to create a matrix of the features to with frequency of joint occurrence in each cell.
In the end , I am looking to create a heatmap of this frequency matrix.
So, my dataframe in R looks like this:
id cat1 cat2 cat3 cat4
156 0 0 1 1
465 1 1 1 0
573 0 1 1 0
The output I want is:
cat1 cat2 cat3 ...
cat1 0 1 0
cat2 1 0 2
cat3 1 2 0
.
.
where each cell value denotes the number of times the two categorical variables have appeared together.