View source: R/demographics-table.R
dem_cont_fun | R Documentation |
Default summary function in pt_demographics for continuous variables
dem_cont_fun(
value = seq(1, 5),
name = "",
...,
fmt = sig,
digits = 3,
maxex = 5
)
value |
a vector or column to summarize |
name |
the name of the variable currently being summarized |
... |
other arguments passed to |
fmt |
a function to format the numbers in the continuous data summary |
digits |
passed to |
maxex |
passed to |
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.
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
pmtables:::dem_cont_fun(value = seq(1,7), digits = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.