# Pairwise Chi-square with missing groups

I'm doing χ2 test for categorical data with more than two categories without problems. I would also like to know which specific categories differ significantly, though, and doing this gives me some NA p-values. As I already figured out (found here), this is because a certain category might not be present in a given pairwise comparison, leading to expected values of zero. Here is an example:

$$\begin{array}{|r|r|r|r|} \hline & cat0 & cat1 & cat2\\ \hline clust2 & 0 & 8 & 2\\ clust3 & 9 & 1 & 0\\ clust4 & 4 & 8 & 0\\ \hline \end{array}$$

This works when using the whole table, but not when only comparing $clust3$ with $clust4$, since $cat2$ is not present then. Would it, in a case like this, be valid to exclude the missing category in order to be able to use chisq.test()?