dem_cont_fun.Rd
Default summary function in pt_demographics for continuous variables
dem_cont_fun(
value = seq(1, 5),
name = "",
...,
fmt = sig,
digits = 3,
maxex = 5
)
a vector or column to summarize
the name of the variable currently being summarized
other arguments passed to fmt
a function to format the numbers in the continuous data summary
passed to fmt
passed to fmt
A tibble with one row and three columns:
Mean (SD)
the mean and standard deviation of value
Min / Max
the range of the value
Missing
the number of missing values
The summary function should have these arguments:
value
the data to summarize
name
the 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.
pmtables:::dem_cont_fun(value = seq(1,7), digits = 2)
#> # A tibble: 1 × 3
#> `Mean (SD)` `Min / Max` Missing
#> <chr> <chr> <chr>
#> 1 4.0 (2.2) 1 / 7 0