Learn R Programming

depigner (version 0.9.1)

tidy_summary: tidy_summary

Description

Converts a summary() object produced by Hmisc or by rms packages to a tidy data frame ready to be `pander`ed (e.g. printed on a word document after knitting the source (with `knitr`).

Usage

tidy_summary(x, ..., digits = 3L)

# S3 method for summary.formula.reverse tidy_summary(x, ..., digits = 3L)

# S3 method for summary.rms tidy_summary(x, ..., digits = 3L)

Value

a [tibble][tibble::tibble-package]

Arguments

x

an object used to select a method, output of some summary by Hmisc.

...

further arguments passed to or from other methods

digits

number of significant digits to use (default 3L).

Methods (by class)

  • tidy_summary(summary.formula.reverse): Tidies a summary reverse output from the summary.formula called with method = "reverse".

  • tidy_summary(summary.rms): Convert the output of the summary.rms into a data frame, reporting only the Hazard Ratio with the .95 CI and the incremental step (for continuous variables) reference (for categorical variables) for which the Hazard is referred to (i.e. without \(\beta\)s, Low, High, S.E. and Type).

Examples

Run this code
# \donttest{
  library(Hmisc)
  my_summary <- summary(Species ~ ., data = iris, method = "reverse")
  tidy_summary(my_summary)
# }
# \donttest{
  library(rms)
  options(datadist = "dd")
  n <- 1000L
  set.seed(731L)
  age <- 50L + 12L * rnorm(n)
  sex <- factor(sample(c("Male", "Female"), n,
    rep = TRUE,
    prob = c(.6, .4)
  ))
  cens <- 15L * runif(n)
  h <- .02 * exp(.04 * (age - 50L) + .8 * (sex == "Female"))
  dt <- -log(runif(n)) / h
  e <- ifelse(dt <= cens, 1L, 0L)
  dt <- pmin(dt, cens)

  dd <- datadist(age, sex)

  S <- survival::Surv(dt, e)
  f <- rms::cph(S ~ age + sex)


  my_summary <- summary(f)
  tidy_summary(my_summary)
# }

Run the code above in your browser using DataLab