Bind contingency table and Pearson Chi-squared residuals.
residuals_table(...)
...
Passed to contingency_table and chisq.test
Matrix