Let’s consider you are given the following dataset mat:
set.seed(1234)
mat<-matrix(sample(c(0,1),50,replace = T),nrow = 10,ncol=5)
rownames(mat) <- paste("patient", paste(1:10),sep="")
colnames(mat) <- c("diabetes", "hypertension", "asthma",
"jointPain", "fever")
> mat
diabetes hypertension asthma jointPain fever
patient1 0 1 0 0 1
patient2 1 1 0 0 1
patient3 1 0 0 0 0
patient4 1 1 0 1 1
patient5 1 0 0 0 0
patient6 1 1 1 1 1
patient7 0 0 1 0 1
patient8 0 0 1 0 0
patient9 1 0 1 1 0
patient10 1 0 0 1 1
The task is to calculate the frequency of each disease and all pair-wise diseases, for example, diabetes and hypertension or diabetes and asthma.