S3 Method for Computing Observed and Expected Frequencies of Univariate and Bivariate Marginals
Useful links