# arsenal v2.0.0

Monthly downloads

## 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;
compare.data.frame(), the S3 method for comparing data.frames; and
write2(), a function to output tables to a document.

## Readme

# The `arsenal`

Package

## Overview

The goal of `library(arsenal)`

is to make statistical reporting easy. It includes many functions which the useR will find useful to have
in his/her "arsenal" of functions. There are, at this time, 6 main functions, documented below. Each of these functions is
motivated by a local SAS macro or procedure of similar functionality.

Note that `arsenal`

v2.0.0 may not be backwards compatible with previous versions.
See the `NEWS`

file for more details.

## The `tableby()`

Function

`tableby()`

is a function to easily summarize a set of independent variables by one or more categorical variables.
Optionally, an appropriate test is performed to test the distribution of the independent variables across
the levels of the categorical variable. Options for this function are easily controlled using `tableby.control()`

.

The `tableby()`

output is easily knitted in an Rmarkdown document or displayed in the command line using the `summary()`

function.
Other S3 methods are implemented for objects from `tableby()`

, including `print()`

, `[`

, `as.data.frame()`

, and `merge()`

.

## The `paired()`

Function

`paired()`

is a function to easily summarize a set of independent variables across two time points.
Optionally, an appropriate test is performed to test the distribution of the independent variables across
the time points. Options for this function are easily controlled using `paired.control()`

.

The `paired()`

output is easily knitted in an Rmarkdown document or displayed in the command line using the `summary()`

function.
It has the same S3 methods as `tableby()`

, since it's a special case of the `tableby()`

object.

## The `modelsum()`

Function

`modelsum()`

is a function to fit and summarize models for each independent variable with one or more response variables,
with options to adjust for covariates for each model. Options for this function are easily controlled using `modelsum.control()`

.

The `modelsum`

output is easily knitted in an Rmarkdown document or displayed in the command line using the `summary()`

function.
Other S3 methods are implemented for objects from `modelsum()`

, including `print()`

, `[`

, `as.data.frame()`

, and `merge()`

.

## The `freqlist()`

Function

`freqlist()`

is a function to approximate the output from SAS's `PROC FREQ`

procedure when using the `/list`

option of the `TABLE`

statement.
Options for this function are easily controlled using `freq.control()`

.

The `freqlist()`

output is easily knitted in an Rmarkdown document or displayed in the command line using the `summary()`

function.
Other S3 methods are implemented for objects from `freqlist()`

, including `print()`

, `[`

, `as.data.frame()`

, and `merge()`

.

## The `compare.data.frame()`

Function

`compare.data.frame()`

is the S3 method for comparing two data.frames and reporting any differences between them,
much like SAS's `PROC COMPARE`

procedure.

The `compare.data.frame()`

output is easily knitted in an Rmarkdown document or displayed in the command line using the `summary()`

function.
Other S3 methods are implemented for objects of class `"compare.data.frame"`

, including `print()`

and `diffs()`

.

## The `write2*()`

Family of Functions

`write2word()`

, `write2pdf()`

, and `write2html()`

are functions to output a table into a document, much like SAS's `ODS`

procedure.
The S3 method behind them is `write2()`

. There are methods implemented for `tableby()`

, `modelsum()`

, `freqlist()`

, and `compare()`

, and
also methods for `knitr::kable()`

, `xtable::xtable()`

, and `pander::pander_return()`

. Another option is to coerce an object using
`verbatim()`

to print out the results monospaced (as if they were in the terminal)--the default method does this automatically.
To output multiple tables into a document, simply make a list of them and call the same function as before. A YAML
header can be added using `yaml()`

. Code chunks can be written using `code.chunk()`

.

For more information, see `vignette("write2")`

.

## Other Notable Functions

`keep.labels()`

keeps the`'label'`

attribute on an R object when subsetting.`formulize()`

is a shortcut to collapse variable names into a formula.`mdy.Date()`

and`Date.mdy()`

convert numeric dates for month, day, and year to Date object, and vice versa.`is.Date`

: tests if an object is a date.`%nin%`

tests for "not in", the negation of`%in%`

.`allNA()`

tests for all elements being NA, and`includeNA()`

makes NAs explicit values.

## Functions in arsenal

Name | Description | |

arsenal_table | arsenal tables with common structure | |

paired.internal | Helper functions for paired | |

as.data.frame.freqlist | as.data.frame.freqlist | |

formulize | formulize | |

freq.control | Control settings for freqlist function | |

reexports | Objects exported from other packages | |

as.data.frame.modelsum | as.data.frame.modelsum | |

compare.data.frame | Compare two data.frames and report differences | |

summary.compare | The summary method for a compare.data.frame object | |

NA.operations | Some functions to handle NAs | |

comparison.control | Control settings for `compare` function | |

as.data.frame.tableby | as.data.frame.tableby | |

%nin% | Not in | |

tableby.control | Control settings for tableby function | |

freqlist | freqlist | |

tableby.internal | Helper functions for tableby | |

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

freqlist.internal | Helper functions for freqlist | |

modelsum.family | Family functions for modelsum | |

mdy.Date | Convert numeric dates to Date object, and vice versa | |

diffs | Extract differences | |

comparison.tolerances | Comparison tolerances | |

mockstudy | Mock study data for examples | |

modelsum.internal | Helper functions for modelsum | |

internal.functions | Split a string into pieces intelligently | |

summary.tableby | The summary method for a tableby object | |

write2 | write2 | |

tableby | Summary Statistics of a Set of Independent Variables by a Categorical Variable | |

write2.internal | Helper functions for write2 | |

write2specific | write2word, write2html, write2pdf | |

paired | Summary Statistics of a Set of Independent Variables Paired Across Two Timepoints | |

padjust | Adjust P-values for Multiple Comparisons | |

tableby.stats | tableby Summary Statistics Functions | |

tableby.stats.internal | Internal tableby functions | |

yaml | Include a YAML header in write2 | |

keep.labels | Keep Labels | |

labels | Labels | |

modelsum.control | Control settings for modelsum function | |

modelsum | Fit models over each of a set of independent variables with a response variable | |

summary.freqlist | summary.freqlist | |

summary.modelsum | Summarize a modelsum object. | |

paired.control | Control settings for paired function | |

No Results! |

## Vignettes of arsenal

Name | ||

compare.Rmd | ||

freqlist.Rmd | ||

labels.Rmd | ||

modelsum.Rmd | ||

paired.Rmd | ||

tableby.Rmd | ||

write2.Rmd | ||

No Results! |

## Last month downloads

## Details

Date | 2019-01-15 |

URL | https://github.com/eheinzen/arsenal, https://cran.r-project.org/package=arsenal |

BugReports | https://github.com/eheinzen/arsenal/issues |

VignetteBuilder | knitr |

License | GPL (>= 2) |

RoxygenNote | 6.1.1 |

LazyData | true |

Encoding | UTF-8 |

NeedsCompilation | no |

Packaged | 2019-01-16 02:39:41 UTC; m144326 |

Repository | CRAN |

Date/Publication | 2019-01-16 05:30:02 UTC |

suggests | broom , coin , gam , knitr , magrittr , MASS , pander , pROC , rmarkdown , rpart , stringr , survival (>= 2.41-3) , xtable , yaml |

depends | R (>= 3.2.0) , stats (>= 3.2.0) |

imports | testthat , utils (>= 3.2.0) |

Contributors | Jason Sinnwell, Elizabeth Atkinson, Tina Gunderson, Gregory Dougherty, Patrick Votruba, Emily Lundt, Ryan Lennon, Krista Goergen, Andrew Hanson, Brendan Broderick, Maddie McCullough |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/arsenal)](http://www.rdocumentation.org/packages/arsenal)
```