ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

Cross classification table with tally()? #805

Open mlaviolet opened 9 months ago

mlaviolet commented 9 months ago

The margins argument to tally() currently supports only column margins, as far as I can tell. It would be useful to expand it to construct a complete cross classification table, perhaps with options "row", "column", or "both". Using 'gmodels::CrossTable()` adds complexity. Thanks!

library(mosaic)
tally(homeless ~ sex, data = HELPrct, margins = TRUE)
#>           sex
#> homeless   female male
#>   homeless     40  169
#>   housed       67  177
#>   Total       107  346

Created on 2024-02-23 with reprex v2.1.0