I have a dataframe which contains many binary categorical variables, and I would like to display a heatmap-like plot for all the observations, only displaying two colors for "yes" and "no" levels. I would then like to sort it so that those observations (ID) with the most "yes" in their row appear on top.
The sample dataset is provided here:
df1 <- data.frame(ID = c(1, 2, 3, 4, 5),
var1 = c('yes', 'yes', 'no', 'yes', 'no'),
var2 = c('no', 'yes', 'no', 'yes', 'no'),
var3 = c('yes', 'no', 'no', 'yes', 'yes'))
df1
ID var1 var2 var3
1 1 yes no yes
2 2 yes yes no
3 3 no no no
4 4 yes yes yes
5 5 no no yes
I tried using the heatmap() function but I could not make it work. Can you please help me with that?

