How can I compare the categorical data of my two columns and visualize it with a 0 if the row is the same for the two columns and if different 1.
If the categorical columns of your dataframe are named x
and y
and have the same levels
you can assign a new column to your dataframe with the result of comparing the two columns using the ifelse
function.
df$match <- ifelse(df$x == df$y, 0, 1)