| Title: | Weighted Cross-Tabulations Exported to 'Excel' |
|---|---|
| Description: | Produces weighted cross-tabulation tables for one or more outcome variables across one or more breakdown variables, and exports them directly to 'Excel'. For each outcome-by-breakdown combination, the package creates a weighted percentage table and a corresponding unweighted count table, with transparent handling of missing values and light, readable formatting. Designed to support social survey analysis workflows that require large sets of consistent, publication-ready tables. |
| Authors: | Siobhan McAndrew [aut, cre] |
| Maintainer: | Siobhan McAndrew <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-06-07 07:09:14 UTC |
| Source: | https://github.com/smmcandrew/tabbitr |
tabbit_excel() produces weighted percentage tables and unweighted counts
for one or more outcome variables, optionally including missing responses
and/or row percentages. Output is written to an Excel file with one sheet per
breakdown variable by default (or all results in a single sheet if
by_breakdown = FALSE).
tabbit_excel( data, vars, breakdown, file, wtvar, row_pct = FALSE, decimals = 1L, nooverall = FALSE, nototal = FALSE, missingasrow = FALSE, nomissing = FALSE, by_breakdown = TRUE, sheet_base = "Frequencies", ... )tabbit_excel( data, vars, breakdown, file, wtvar, row_pct = FALSE, decimals = 1L, nooverall = FALSE, nototal = FALSE, missingasrow = FALSE, nomissing = FALSE, by_breakdown = TRUE, sheet_base = "Frequencies", ... )
data |
A data frame. |
vars |
Character vector of outcome variable names. |
breakdown |
Character vector of breakdown variables. |
file |
Path to the Excel file to create. |
wtvar |
Name of the weight variable (string). Must be present in |
row_pct |
Logical. If |
decimals |
Integer. Number of decimal places for percentages (0-6; default 1). |
nooverall |
Logical. If |
nototal |
Logical. If |
missingasrow |
Logical. If |
nomissing |
Logical. If |
by_breakdown |
Logical. If |
sheet_base |
Sheet name to use when |
... |
For future extension; may include |
For each outcome variable in vars and each breakdown variable in
breakdown, tabbit_excel():
computes weighted percentages (by column or by row),
optionally adds an overall distribution across breakdowns,
optionally adds a "Total percent" row (column mode only),
handles missing outcomes either as a separate "Response missing" row or by excluding them, with or without a separate "Missing percent" line, and
writes a corresponding unweighted N table including (or excluding) missing responses.
A light formatting layer is applied using the openxlsx package:
table headers: bold, with top and bottom borders,
row labels: bold,
total rows ("Total percent" and "Column totals"): bold, with top and bottom borders, and
missing-percentage row: italic.
Invisibly, the file path of the created workbook (a character string).
## Not run: tabbit_excel( data = survey_df, vars = c("courteous", "listener"), breakdown = c("sex", "agegrp1"), file = "results.xlsx", wtvar = "w_caltrim_c", row_pct = FALSE, decimals = 1L, nooverall = FALSE, nototal = FALSE, missingasrow = FALSE, nomissing = FALSE ) ## End(Not run)## Not run: tabbit_excel( data = survey_df, vars = c("courteous", "listener"), breakdown = c("sex", "agegrp1"), file = "results.xlsx", wtvar = "w_caltrim_c", row_pct = FALSE, decimals = 1L, nooverall = FALSE, nototal = FALSE, missingasrow = FALSE, nomissing = FALSE ) ## End(Not run)