Description Usage Arguments Examples
A function that takes a single dependent variable with a vector of explanatory variable names (continuous or categorical variables) to produce a summary table.
1 2 3 |
df |
Dataframe |
dependent |
Character vector of length 1: name of depdendent variable (2 to 5 factor levels) |
explanatory |
Character vector of any length: name(s) of explanatory variables |
cont |
Summary for continuous variables: mean (standard deviation) or median (interquartile range) |
p |
Logical: Include statistical test (see |
na.include |
Logical: include missing data in summary ( |
column |
Logical: Compute margins by column rather than row |
total_col |
Logical: include a total column summing across factor levels |
orderbytotal |
Logical: order final table by total column high to low |
glm.id |
Logical: not used directly, allows merging via |
na.to.missing |
Logical: convert |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # summary.factorlist() wraps `Hmisc::summary.formula` to summarise any number of variables by a single categorical
# variable. This is usually "Table 1" of a study report.
library(summarizer)
library(tidyverse)
# Load example dataset, modified version of survival::colon
data(colon_s)
# Table 1 - Patient demographics ----
explanatory = c("age", "age.factor", "sex.factor", "obstruct.factor")
dependent = "perfor.factor"
colon_s %>%
summary.factorlist(dependent, explanatory, p=T)
# summary.factorlist() is also commonly used to summarise any number of variables by an outcome variable (say dead yes/no).
# Table 2 - 5 yr mortality ----
explanatory = c("age.factor", "sex.factor", "obstruct.factor", "perfor.factor")
dependent = 'mort_5yr'
colon_s %>%
summary.factorlist(dependent, explanatory)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.