tidy_override: Change a model's 'tidy' output

tidy_overrideR Documentation

Change a model's tidy output

Description

Use tidy_override and tidy_replace to provide your own p values, confidence intervals etc. for a model.

Usage

tidy_override(x, ..., glance = list(), extend = FALSE)

tidy_replace(x, tidied, glance = list())

## S3 method for class 'tidy_override'
tidy(x, ...)

## S3 method for class 'tidy_override'
glance(x, ...)

## S3 method for class 'tidy_override'
nobs(object, ...)

Arguments

x

A model with methods defined for generics::tidy() and/or generics::glance().

...

In tidy_override, columns of statistics to replace tidy output. In tidy and glance methods, arguments passed on to the underlying model.

glance

A list of summary statistics for glance.

extend

Logical: allow adding new columns to tidy(x) and glance(x)?

tidied

Data frame to replace the result of tidy(x).

object

A tidy_override object.

Details

tidy_override allows you to replace some columns of tidy(x) with your own data.

tidy_replace allows you to replace the result of tidy(x) entirely.

Value

An object that can be passed in to huxreg.

Examples

if (! requireNamespace("broom", quietly = TRUE)) {
  stop("Please install 'broom' to run this example.")
}

lm1 <- lm(mpg ~ cyl, mtcars)
fixed_lm1 <- tidy_override(lm1,
      p.value = c(.04, .12),
      glance = list(r.squared = 0.99))
huxreg(lm1, fixed_lm1)

if (requireNamespace("nnet", quietly = TRUE)) {
  mnl <- nnet::multinom(gear ~ mpg, mtcars)
  tidied <- broom::tidy(mnl)
  mnl4 <- tidy_replace(mnl, tidied[tidied$y.level == 4, ])
  mnl5 <- tidy_replace(mnl, tidied[tidied$y.level == 5, ])
  huxreg(mnl4, mnl5, statistics = "nobs")
}


huxtable documentation built on Oct. 2, 2024, 1:06 a.m.