cols_cont - a vector of names (possibly renamed) of continuous data columns
cols_cat - a vector of names (possibly renamed) of categorical data columns
Optional
span - the column name containing spanner information (possibly renamed)
units - a named list of units ... list(WT = "(kg)")
stat_name - a label for the left hand side of the table listing summary stats
stat_width - the width (in cm) of the Statistic column
all_name - the column name for the All data summary
paneled - should the table be paneled? Or wider format?
fun - a function to summarize continuous data
notes - replace the default notes
Return value
An object with class pmtable; this is a list and the summarised data are in data slot
Summary function
... is a required argument; there will be an error if the user specifies a custom summary function and doesn't have ... in the signature
arg 1: value ... the data to summarize
arg 2: name ... the name of the column that is being summarized
arg 3: ... other arguments passed to the format function
fmt the default format function
digits passed to fmt
maxex passed to fmt
Note that the default fmt function is pmtables::sig(); the signature for sig() as well as digit1() have been expanded to include ... so that can absorb any unused argument; I'm also exporting rnd() which is just round() with ....
Additional changes
Along the way, we made these changes
Refactor new_names.character to handle mix of named and non-named items
Added utility function ensure_parens which will look for items in a vector or list and wrap in parens if they are not detected
History
See #227; Kyle Baron opened up the current PR so that @barrettk and others could comment and review. The summary and notes are copied here as well.
Summary
Vignette / Examples
Update: 17 Aug 2021 test-demographics.pdf
Update: 10 Aug 2021 test-demographics.pdf
Update: 9 Aug 2021 test-demographics.pdf
Initial version: test-demographics.pdf
Required arguments
data
- a data frame to summarizecols_cont
- a vector of names (possibly renamed) of continuous data columnscols_cat
- a vector of names (possibly renamed) of categorical data columnsOptional
span
- the column name containing spanner information (possibly renamed)units
- a named list of units ...list(WT = "(kg)")
stat_name
- a label for the left hand side of the table listing summary statsstat_width
- the width (in cm) of theStatistic
columnall_name
- the column name for theAll data
summarypaneled
- should the table be paneled? Or wider format?fun
- a function to summarize continuous datanotes
- replace the default notesReturn value
pmtable
; this is a list and the summarised data are indata
slotSummary function
...
is a required argument; there will be an error if the user specifies a custom summary function and doesn't have...
in the signaturevalue
... the data to summarizename
... the name of the column that is being summarized...
other arguments passed to the format functionfmt
the default format functiondigits
passed tofmt
maxex
passed tofmt
Note that the default
fmt
function ispmtables::sig()
; the signature forsig()
as well asdigit1()
have been expanded to include...
so that can absorb any unused argument; I'm also exportingrnd()
which is justround()
with...
.Additional changes
Along the way, we made these changes
new_names.character
to handle mix of named and non-named itemsensure_parens
which will look for items in a vector or list and wrap in parens if they are not detected