Skip to contents

A minimum alternative to summarytools::dfSummary to avoid package dependency.

Usage

summarizeDataFrame(
  data,
  exclude_vars = NULL,
  tte_vars = NULL,
  event_vars = NULL,
  categorical_vars = NULL
)

Arguments

data

a data frame.

exclude_vars

columns to be excluded from summary.

tte_vars

character. Vector of time-to-event variables.

event_vars

character. Vector of event indicators. Every time-to-event variable should be corresponding to an event indicator.

categorical_vars

character. Vector of categorical variables. This can be used to specify variables with limited distinct values as categorical variables in summary.

Value

a data frame of summary

Examples


set.seed(123)

n <- 1000
data <- data.frame(
  age = rnorm(n, 65, 10),
  gender = sample(c('M', 'F', NA), n, replace = TRUE, prob = c(.4, .4, .2)),
  time_to_death = rexp(n, .01),
  death = rbinom(n, 1, .6),
  type = sample(LETTERS[1:8], n, replace = TRUE)
)

summarizeDataFrame(data, tte_vars = 'time_to_death', event_vars = 'death')
#> Summary generated.