Learn R Programming

DMAR (version 1.0.0)

print_anova: Print a Model Comparison or ANOVA Table With DMAR p-value Formatting

Description

Pretty-print an ANOVA-like object (the output of stats::anova, car::Anova, lmerTest::anova, etc.) with p-values formatted at a fixed number of decimal places (default 4) and with a “< 10^(-digits_p)” floor for values too small to express. The default behavior of print.anova routes p-values through stats::format.pval, which applies its own digit rule (max(1L, getOption("digits") - 2L)) and switches to scientific notation for tiny values. print_anova() sidesteps that by converting the p-value columns to character strings up front and printing as a data frame.

Usage

print_anova(x, digits_p = 4L)

Value

The input x, invisibly and unchanged.

Arguments

x

An ANOVA-like data frame with one or more Pr(...) columns. Accepts anova objects from stats::anova, car::Anova, car::Manova, and lmerTest::anova.

digits_p

Integer number of decimal places for the p-value column(s). Default 4L.

Author

Ken Kelley

Details

The returned object is the input x invisibly, unchanged: the underlying numeric p-values retain full precision and can still be indexed (for example as x[["Pr(>F)"]]).

Any column whose name starts with Pr( is formatted as a p-value column. Other columns print at whatever getOption("digits") dictates (so set options(digits = 4) for a uniformly compact display).

See Also

format_p, print_summary.

Examples

Run this code
fit <- lm(weight ~ Time + Diet, data = ChickWeight)
print_anova(anova(fit))

print_anova(car::Anova(fit, type = "III"))

# Underlying numeric p-values are untouched:
a <- anova(fit)
print_anova(a)
a[["Pr(>F)"]]   # full-precision doubles

Run the code above in your browser using DataLab