Type: | Package |
Title: | Build Common Tables of Summary Statistics for Reports |
Version: | 0.2.2 |
Description: | Mainly used to build tables that are commonly presented for bio-medical/health research, such as basic characteristic tables or descriptive statistics. |
License: | MIT + file LICENSE |
LazyData: | TRUE |
Imports: | dplyr, magrittr, tidyr, pander, utils, stats, lazyeval, tibble |
RoxygenNote: | 6.1.1 |
Suggests: | knitr, rmarkdown, testthat, covr |
VignetteBuilder: | knitr |
URL: | https://github.com/lwjohnst86/carpenter |
BugReports: | https://github.com/lwjohnst86/carpenter/issues |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2019-01-31 12:50:30 UTC; luke |
Author: | Luke Johnston |
Maintainer: | Luke Johnston <lwjohnst@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-02-05 08:43:30 UTC |
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Add rows to the table with summary statistics.
Description
Add rows to the table with summary statistics.
Usage
add_rows(data, row_vars, stat, digits = 1)
Arguments
data |
Output from the |
row_vars |
The variables that you want added to the table. Must be from
|
stat |
The summary statistic or any other function. A list of
built functions can be found in |
digits |
What to round the value to. |
Value
Adds a row with summary statistics for a variable. Is a tibble.
See Also
carpenter()
for a list of all functions, examples, and
accessing the introduction tutorial vignette. See table_stats()
for a list of carpenter builtin statistics.
Build the final table.
Description
Output can be to common formats such as rmarkdown, html, etc, based on the
style
argument of the pander::pander()
function.
Usage
build_table(data, caption = NULL, style = "rmarkdown", split = Inf,
missing = "", alignment = "center", finish = TRUE)
Arguments
data |
The draft table object. |
caption |
Table caption. |
style |
What output style (rmarkdown, grid, simple, etc) should the table be. |
split |
When should the table split when it is too wide? (Inf means never). |
missing |
How to deal with missing values in the table (removed by default). |
alignment |
Table column alignment. |
finish |
Generate the final table in markdown formatted form. |
Value
Creates a pander::pander()
created table.
See Also
carpenter()
for a list of all functions, examples, and
accessing the introduction tutorial vignette.
Build common tables for your research needs!
Description
Build common tables for your research needs!
See Also
add_rows()
to add rows to the table,
renaming()
for renaming of columns and rows,
build_table()
, table_stats()
for a list of built-in
summary statistics. For a more detailed walkthrough of carpenter, see the
introduction vignette using vignette('carpenter')
.
Examples
library(magrittr)
outline_table(iris, 'Species') %>%
add_rows(c('Sepal.Length', 'Petal.Length'), stat_meanSD) %>%
add_rows('Sepal.Width', stat_medianIQR) %>%
renaming('rows', function(x) gsub('Sepal\\.', 'Sepal ', x)) %>%
renaming('header', c('Measures', 'Setosa', 'Versicolor', 'Virginica')) %>%
build_table(caption = 'A caption for the table')
Make an outline of the table you want to create.
Description
Make an outline of the table you want to create.
Usage
outline_table(data, header = NULL)
Arguments
data |
Dataset to use to create the table |
header |
Column or variable(s) that will make up the rows |
Value
Dataframe ready for further carpentry work, like adding rows, summary statistics, renaming, etc.
See Also
carpenter()
for a list of all functions, examples, and
accessing the introduction tutorial vignette.
Renaming row and header variables.
Description
Renaming row and header variables.
Usage
renaming(data, type = c("rows", "header"), replace)
Arguments
data |
The |
type |
Whether to rename the row column or the headers. |
replace |
If type is 'row', needs to be a function (anonymous or otherwise)
using the |
Value
Adds to the table outline to rename the rows and/or header variables in the final table.
See Also
carpenter()
for a list of all functions, examples, and
accessing the introduction tutorial vignette.
Common summary statistics to use in add_rows()
.
Description
Common summary statistics to use in add_rows()
.
Usage
stat_median(x, digits = 1)
stat_iqr(x, digits = 1)
stat_medianIQR(x, digits = 1)
stat_mean(x, digits = 1)
stat_stddev(x, digits = 1)
stat_meanSD(x, digits = 1)
stat_nPct(x, digits = 0)
Arguments
x |
Numeric vector to use to calculate the statistic |
digits |
Number of digits to use |
Value
Create a single character string with the summary statistic
See Also
carpenter()
for a list of all functions, examples, and
accessing the introduction tutorial vignette.