
Default summary function in pt_demographics for continuous variables
Source:R/demographics-table.R
dem_cont_fun.RdDefault summary function in pt_demographics for continuous variables
Usage
dem_cont_fun(
value = seq(1, 5),
name = "",
...,
fmt = sig,
digits = 3,
maxex = 5
)Value
A tibble with one row and three columns:
Mean (SD)the mean and standard deviation ofvalueMin / Maxthe range of thevalueMissingthe number of missingvalues
Details
The summary function should have these arguments:
valuethe data to summarizenamethe name of the data column being summarized; length 1...absorbs other arguments that might get passed
These are the important arguments; name is not required as a formal
argument but ... is. The idea is that the custom summary function
receives the data to be summarized, the name of that data, and other
arguments. Since you are in charge of the function, you can make decisions
about both summaries and the formatting of those summaries inside the
function you are maintaining. Notice that dem_cont_fun also contains
arguments fmt (a formatting function) and digits and maxex (arguments
to be passed to fmt). This means that you can have your summary function
call the default summary function but with different formatting parameters.
The summary function should return a data frame, with summary statistics in the columns.
Examples
pmtables:::dem_cont_fun(value = seq(1,7), digits = 2)
#> # A tibble: 1 × 4
#> `Mean (SD)` Median `Min / Max` Missing
#> <chr> <chr> <chr> <chr>
#> 1 4.0 (2.2) 4 1 / 7 0