ff_column_totals {finalfit}R Documentation

Add column totals to summary_factorlist() output

Description

Add column totals to summary_factorlist() output

Usage

ff_column_totals(
  df.in,
  .data,
  dependent,
  na_include_dependent = FALSE,
  percent = TRUE,
  digits = c(1, 0),
  label = NULL,
  prefix = "",
  weights = NULL
)

finalfit_column_totals(
  df.in,
  .data,
  dependent,
  na_include_dependent = FALSE,
  percent = TRUE,
  digits = c(1, 0),
  label = NULL,
  prefix = "",
  weights = NULL
)

Arguments

df.in

summary_factorlist() output.

.data

Data frame used to create summary_factorlist().

dependent

Character. Name of dependent variable.

na_include_dependent

Logical. When TRUE, missing data in the dependent variable is included in totals.

percent

Logical. Include percentage.

digits

Integer length 2. Number of digits for (1) percentage, (2) weighted count.

label

Character. Label for total row.

prefix

Character. Prefix for column totals, e.g "N=".

weights

Character vector of length 1: name of column to use for weights.

Value

Data frame.

Examples

explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
 summary_factorlist(dependent, explanatory) %>%
 ff_column_totals(colon_s, dependent)

# Ensure works with missing data in dependent
colon_s = colon_s %>%
 dplyr::mutate(
  mort_5yr = forcats::fct_na_value_to_level(mort_5yr, level = "(Missing)")
 )
 colon_s %>%
 summary_factorlist(dependent, explanatory) %>%
 ff_column_totals(colon_s, dependent)

[Package finalfit version 1.0.8 Index]