Weighted Cross-Tabulations Exported to 'Excel'

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.


tabbitR

Weighted crosstabulation tables exported to Excel.

R-CMD-check License:MIT

Overview

tabbitR automates the production of large sets of weighted crosstabulation tables and exports them directly to Excel. It is designed for situations where analysts need many tables at once:

  • multiple outcome variables
  • multiple breakdown (explanatory) variables
  • weighted percentages
  • unweighted counts
  • transparent treatment of missing values.

This is a common and time-consuming task in survey research, monitoring and evaluation work, and exploratory data analysis. Doing it manually is slow, repetitive, and error-prone.

tabbitR solves this by generating a full and consistent set of tables in a single command. For each outcome by breakdown pair, it writes:

  • a weighted percentage table
  • a matching unweighted N table
  • clearly labelled reporting of missing values
  • light formatting (headers, borders, bold labels) using {openxlsx}.

User options control:

  • number of decimal places
  • row vs.column percentages
  • whether to show overall % columns or total rows
  • how missing responses should be reported
  • whether to create one sheet per breakdown variable.

Installation

You can install the development version of tabbitR from GitHub with pak:

install.packages("pak")
pak::pak("smmcandrew/tabbitR")

or with remotes:

remotes::install_github("smmcandrew/tabbitR")

Example

Below is a minimal example using toy data.

library(tabbitR)

df <- data.frame(
  outcome = factor(c("A", "B", "A", NA, "C", NA)),
  sex     = factor(c("Male", "Male", "Female", "Female", "Prefer not to say", "Male")),
  weight  = c(1, 2, 1, 1, 0.75, 3)
)

tabbit_excel(
  data        = df,
  vars        = "outcome",
  breakdown   = "sex",
  wtvar       = "weight",
  file        = "example_output.xlsx",
  decimals    = 2
)

This will create an Excel workbook with a weighted percentage table and unweighted N table for each frequency or breakdown, automatically formatted and labelled.

Development notes

This README is generated from README.Rmd. Use:

devtools::build_readme()

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("tabbitR")

0.1.3 by Siobhan McAndrew, 8 months ago


https://github.com/smmcandrew/tabbitR


Report a bug at https://github.com/smmcandrew/tabbitR/issues


Browse source code at https://github.com/cran/tabbitR


Authors: Siobhan McAndrew [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports haven, openxlsx, stats

Suggests knitr, rmarkdown


See at CRAN