sum_crosstab: Crosstabulation with Counts and Percentages
Description
Creates a cross-tabulation (contingency table) between two categorical variables
and returns a publication-ready table as a flextable. The table displays
cell counts with optional percentages (cell-wise, row-wise, or column-wise),
and includes row totals (right) and column totals (bottom).
A flextable object containing the formatted cross-tabulation
with counts, optional percentages, and marginal totals.
Arguments
data
A data frame containing the variables to be cross-tabulated.
row_var
A character string specifying the row variable (categorical).
col_var
A character string specifying the column variable (categorical).
percent
Type of percentage to display alongside counts. One of
"none" (counts only), "cell" (percentage of total),
"row" (row percentage), or "col" (column percentage).
digits
Integer specifying the number of decimal places for percentages.