tidy_summary: tidy_summary

View source: R/tidy_summary.R

tidy_summaryR Documentation

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 class 'summary.formula.reverse'
tidy_summary(x, ..., digits = 3L)

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

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).

Value

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

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 \betas, Low, High, S.E. and Type).

Note

The output is supposed to be used as input to [pander][pander::pander], and contains few otherwise messy characters included for an optimal (pander) formatting.

to see the options you can pass to ... for a custom print, see the print section in summary.formula.

Examples


  library(Hmisc)
  my_summary <- summary(Species ~ ., data = iris, method = "reverse")
  tidy_summary(my_summary)


  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)


depigner documentation built on April 24, 2023, 5:08 p.m.