dem_cont_fun: Default summary function in pt_demographics for continuous...

View source: R/demographics-table.R

dem_cont_funR Documentation

Default summary function in pt_demographics for continuous variables

Description

Default summary function in pt_demographics for continuous variables

Usage

dem_cont_fun(
  value = seq(1, 5),
  name = "",
  ...,
  fmt = sig,
  digits = 3,
  maxex = 5
)

Arguments

value

a vector or column to summarize

name

the name of the variable currently being summarized

...

other arguments passed to fmt

fmt

a function to format the numbers in the continuous data summary

digits

passed to fmt

maxex

passed to fmt

Details

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.

Value

A tibble with one row and three columns:

  1. Mean (SD) the mean and standard deviation of value

  2. Min / Max the range of the value

  3. Missing the number of missing values

Examples

pmtables:::dem_cont_fun(value = seq(1,7), digits = 2)


metrumresearchgroup/pmtables documentation built on Dec. 22, 2024, 1:34 a.m.