Package: arsenal 3.7.1

Ethan Heinzen

arsenal: An Arsenal of 'R' Functions for Large-Scale Statistical Summaries

An Arsenal of 'R' functions for large-scale statistical summaries, which are streamlined to work within the latest reporting tools in 'R' and 'RStudio' and which use formulas and versatile summary statistics for summary tables and models. The primary functions include tableby(), a Table-1-like summary of multiple variable types 'by' the levels of one or more categorical variables; paired(), a Table-1-like summary of multiple variable types paired across two time points; modelsum(), which performs simple model fits on one or more endpoints for many variables (univariate or adjusted for covariates); freqlist(), a powerful frequency table across many categorical variables; comparedf(), a function for comparing data.frames; and write2(), a function to output tables to a document.

Authors:Ethan Heinzen [aut, cre], Jason Sinnwell [aut], Elizabeth Atkinson [aut], Tina Gunderson [aut], Gregory Dougherty [aut], Patrick Votruba [ctb], Ryan Lennon [ctb], Andrew Hanson [ctb], Krista Goergen [ctb], Emily Lundt [ctb], Brendan Broderick [ctb], Maddie McCullough [art]

arsenal_3.7.1.tar.gz
arsenal_3.7.1.tar.gz(r-4.7-any)arsenal_3.7.1.tar.gz(r-4.6-any)
arsenal_3.7.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
arsenal/json (API)

# Install 'arsenal' in R:
install.packages('arsenal', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/mayoverse/arsenal/issues

Pkgdown/docs site:https://mayoverse.github.io

Datasets:

On CRAN:

Conda:

9.12 score 2 stars 6 packages 1.9k scripts 5.4k downloads 11 mentions 112 exports 6 dependencies

Last updated from:8af07b7158. Checks:4 OK. Indexed: no.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK219
source / vignettesOK201
linux-release-x86_64OK215
wasm-releaseOK147

Exports:%nin%allNAas.selectallas.tbstatas.tbstat_multirowbinomCIclogcode.chunkcomparedfcomparedf.controlcountcellpctcountNcountpctcountrowpctDate.mdydiffsformulizefreq.controlfreqlistgmeangmeanCIgmeansdgsdhas_strataincludeNAiqris.Dateis.freqlistis.modelsumis.selectallis.summary.freqlistis.summary.modelsumis.summary.tablebyis.tablebyis.yamlkeep.labelslabels<-loosen.labelsmdy.DatemeanCImeanpmsdmeanpmsemeansdmeansemedianmadmedianq1q3medianrangemedSurvmedSurvCImedSurvQuantmedTimemodelsummodelsum.controlmodpval.tablebymuck_up_mockstudyNn.diff.obsn.diffsna.modelsumna.pairedna.tablebynegbinNeventsNeventsSurvNmissNmiss2NmisspctNmisspct2NpctNriskNriskSurvNrowpctNsigntestordinalpadjustpairedpaired.controlpctq1q3relriskreplace2rowbinomCIrowpctselectallset_attrset_labelssmart.splitsurvivaltablebytableby.controltbfmtteststol.char.bothtol.char.casetol.char.nonetol.char.trimtol.date.absolutetol.factor.labelstol.factor.levelstol.factor.nonetol.logical.nonetol.NAtol.num.absolutetol.num.pcttol.num.percenttol.other.noneverbatimwrite2write2htmlwrite2pdfwrite2wordyaml

Dependencies:evaluategluehighrknitrxfunyaml

A Few Notes on Labels
Introduction | Examples | Set labels in the function call | Modify labels after the fact | Add labels to a data.frame | When labels get long

Last update: 2026-07-02
Started: 2017-08-14

The comparedf function
Introduction | Basic examples | A larger example | Column name comparison options | Ignoring case | Treating dots and underscores the same (equivalence classes) | Manually specifying columns to match together | Column comparison options | Logical tolerance | Numeric tolerance | Factor tolerance | Character tolerance | Date tolerance | Other data type tolerances | Specifying tolerances for each variable | User-defined tolerance functions | Details | Example 1 | Example 2 | Extract Differences | Appendix | Stucture of the Object

Last update: 2026-07-02
Started: 2019-03-25

The freqlist function
Overview | Sample dataset | The freqlist object | Basic output using summary() | Using a formula with freqlist | Rounding percentage digits or changing variable names for printing | Additional examples | Including combinations with frequencies of zero | Options for NA handling | Frequency counts and percentages subset by factor levels | Show only the "n" most common combinations in each table (head() and sort()) | Change labels on the fly | Using xtable() to format and print freqlist() results | Use freqlist in bookdown | Appendix: Notes regarding table options in R | NAs | Table dimname names (dnn)

Last update: 2026-07-02
Started: 2016-12-30

The modelsum function
Introduction | Simple Example | Pretty text version of table | Pretty Rmarkdown version of table | Data frame version of table | Add an adjustor to the model | Models for each endpoint type | Gaussian | Fit and summarize linear regression model | Extract data using the broom package | Create a summary table using modelsum | Binomial | Fit and summarize logistic regression model | Extract data using broom package | Survival | Fit and summarize a Cox regression model | Poisson | Example 1: fit and summarize a Poisson regression model | Example 2: fit and summarize a Poisson regression model | Additional Examples | 1. Change summary statistics globally | 2. Add labels to independent variables | 3. Don't show intercept values | 4. Don't show results for adjustment variables | 5. Summarize multiple variables without typing them out | 6. Subset the dataset used in the analysis | 7. Create combinations of variables on the fly | 8. Transform variables on the fly | 9. Change the ordering of the variables or delete a variable | 10. Merge two modelsum objects together | 11. Add a title to the table | 12. Modify how missing values are treated | 13. Modify the number of digits used | 14. Use case-weights in the models | 15. Use modelsum within an Sweave document | 16. Export modelsum results to a .CSV file | 17. Write modelsum object to a separate Word or HTML file | 18. Use modelsum in R Shiny | 23. Use modelsum in bookdown | 24. Model multiple endpoints | 25. Model data by a non-test group (strata) | 26. Add multiple sets of adjustors to the model | Available Function Options | Summary statistics | modelsum.control settings | summary.modelsum settings

Last update: 2026-07-02
Started: 2016-12-30

The paired function
Introduction | Simple Example | NAs | Available Function Options | Testing options | paired.control settings | summary.tableby settings

Last update: 2026-07-02
Started: 2018-07-20

The tableby function
Introduction | Simple Example | Pretty text version of table | Pretty Rmarkdown version of table | Data frame version of table | Summaries using standard R code | Modifying Output | Add labels | Change summary statistics globally | Change summary statistics within the formula | Controlling Options for Categorical Tests (Chisq and Fisher's) | Modifying the look & feel in Word documents | Additional Examples | 1. Summarize without a group/by variable | 2. Display footnotes indicating which "test" was used | 3. Summarize an ordered factor | 4. Summarize a survival variable | 5. Summarize date variables | 6. Summarize multiple variables without typing them out | 7. Subset the dataset used in the analysis | 8. Create combinations of variables on the fly | 9. Transform variables on the fly | 10. Subsetting (change the ordering of the variables, delete a variable, sort by p-value, filter by p-value, show only certain by-levels) | 11. Merge two tableby objects together | 12. Add a title to the table | 13. Modify how missing values are displayed | 14. Modify the number of digits used | 15. Create a user-defined summary statistic | 16. Use case-weights for creating summary statistics | 17. Create your own p-value and add it to the table | 18. For two-level categorical variables or one-line numeric variables, simplify the output. | 19. Use tableby within an Sweave document | 20. Export tableby object to a .CSV file | 21. Write tableby object to a separate Word or HTML file | 22. Use tableby in R Shiny | 23. Use tableby in bookdown | 24. Adjust tableby for multiple p-values | 25. Tabulate multiple endpoints | 26. Tabulate data by a non-test group (strata) | Available Function Options | Summary statistics | Testing options | tableby.control settings | summary.tableby settings

Last update: 2026-07-02
Started: 2016-12-30

The write2 function
Introduction | A note on piping | Examples Using arsenal Objects | tableby | modelsum | freqlist | comparedf | Examples Using Other Objects | knitr::kable() | xtable::xtable() | pander::pander_return() | Output Multiple Tables to One Document | Output Other Objects Monospaced (as if in a terminal) | Add a YAML Header to the Output | Add a Code Chunk to the Output | FAQs | How do I suppress the note about my document getting rendered? | How do I look at the temporary .Rmd file? | How do I prevent my document from being rendered? | How do I output headers, raw HTML/LaTeX, paragraphs, etc.? | How do I tweak the default format from write2word(), write2html(), or write2pdf()? | How do I output to a file format other than word, HTML, and PDF? | How do I avoid prefixes on my table captions in PDF? | How do I output multiple tables with different titles? | Why is write2() not working in R Markdown/R Studio?

Last update: 2026-07-02
Started: 2017-01-31

Readme and manuals

Help Manual

Help pageTopics
An Arsenal of 'R' Functions for Large-Scale Statistical Summariesarsenal-package arsenal
Not in%nin% nin
'arsenal' tables with common structurearsenal_table has_strata labels.arsenal_table labels<-.arsenal_table merge.arsenal_table merge.freqlist print.arsenal_table print.summary.arsenal_table [.arsenal_table [.tableby
Defunct functions in 'arsenal'arsenal-defunct
Deprecated functions in 'arsenal'arsenal-deprecated
as.data.frame.freqlistas.data.frame.freqlist
as.data.frame.modelsumas.data.frame.modelsum
as.data.frame.tablebyas.data.frame.tableby
Compare two data.frames and report differencescomparedf print.comparedf
Control settings for 'comparedf' functioncomparedf.control
'comparedf' tolerancescomparedf.tolerances tol.char.both tol.char.case tol.char.none tol.char.trim tol.date.absolute tol.factor.labels tol.factor.levels tol.factor.none tol.logical.none tol.NA tol.num.absolute tol.num.pct tol.num.percent tol.other.none
Extract differencesdiffs diffs.comparedf diffs.summary.comparedf n.diff.obs n.diff.obs.comparedf n.diff.obs.summary.comparedf n.diffs n.diffs.comparedf n.diffs.summary.comparedf
formulizeformulize
Control settings for 'freqlist' functionfreq.control
freqlistfreqlist freqlist.formula freqlist.table
Helper functions for freqlistfreqlist.internal head.summary.freqlist is.freqlist is.summary.freqlist sort.freqlist tail.summary.freqlist
Internal Functionsinternal.functions replace2 smart.split
Keep Labelskeep.labels keep.labels.data.frame keep.labels.default loosen.labels loosen.labels.data.frame loosen.labels.default [.keep_labels [<-.keep_labels
Labelslabels labels.data.frame labels.keep_labels labels<- labels<-.data.frame labels<-.default labels<-.keep_labels set_attr set_labels
Convert numeric dates to Date object, and vice versaDate.mdy is.Date mdy.Date
Mock study data for examplesmockstudy muck_up_mockstudy
Fit models over each of a set of independent variables with a response variablemodelsum
Control settings for 'modelsum' functionmodelsum.control
Family functions for modelsumclog modelsum.family negbin ordinal relrisk survival
Helper functions for modelsumis.modelsum is.summary.modelsum modelsum.internal na.modelsum
Some functions to handle NAsallNA includeNA includeNA.default includeNA.factor NA.operations
Adjust P-values for Multiple Comparisonspadjust padjust.default padjust.summary.tableby padjust.tableby
Summary Statistics of a Set of Independent Variables Paired Across Two Timepointspaired
Control settings for 'paired' functionpaired.control
Helper functions for pairedna.paired paired.internal
Make a column for "select all" inputas.matrix.selectall as.selectall is.na.selectall is.selectall selectall [.selectall
The summary method for a 'comparedf' objectprint.summary.comparedf summary.comparedf
summary.freqlistas.data.frame.summary.freqlist summary.freqlist
Summarize a 'modelsum' object.as.data.frame.summary.modelsum summary.modelsum
The summary method for a 'tableby' objectas.data.frame.summary.tableby summary.tableby
Summary Statistics of a Set of Independent Variables by a Categorical Variabletableby
Control settings for 'tableby' functiontableby.control
Helper functions for tablebyhead.tableby is.summary.tableby is.tableby modpval.tableby na.tableby Ops.tableby sort.tableby tableby.internal tail.tableby tests tests.tableby xtfrm.tableby
tableby Summary Statistics Functionsarsenal_max arsenal_mean arsenal_median arsenal_min arsenal_range arsenal_sd arsenal_sum arsenal_var binomCI count countcellpct countN countpct countrowpct gmean gmeanCI gmeansd gsd iqr meanCI meanpmsd meanpmse meansd meanse medianmad medianq1q3 medianrange medSurv medSurvCI medSurvQuant medTime N Nevents NeventsSurv Nmiss Nmiss2 Nmisspct Nmisspct2 Npct Nrisk NriskSurv Nrowpct Nsigntest pct q1q3 rowbinomCI rowpct tableby.stats
Internal 'tableby' functionsas.tbstat as.tbstat_multirow tableby.stats.internal tbfmt
write2write2 write2.arsenal_table write2.character write2.code.chunk write2.comparedf write2.default write2.knitr_kable write2.list write2.summary.arsenal_table write2.summary.comparedf write2.verbatim write2.xtable write2.yaml
Helper functions for 'write2'code.chunk verbatim write2.internal
write2word, write2html, write2pdfwrite2html write2pdf write2specific write2word
Include a YAML header in 'write2'c.yaml is.yaml print.yaml yaml