melliotab: Create a formatted statistical table

View source: R/melliotab.R

melliotab.mediateR Documentation

Create a formatted statistical table

Description

The main entry point for melliotab. Accepts data frames, model objects, or correlation matrices and formats them according to the specified citation style. Passing two or more model objects creates a side-by-side model comparison table.

Usage

## S3 method for class 'mediate'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'summary.mediate'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'medSummary'
melliotab(x, ..., section = NULL)

## S3 method for class 'medSummary2'
melliotab(x, ..., section = NULL)

## S3 method for class 'modmedSummary'
melliotab(x, ..., section = NULL)

## S3 method for class 'modmedSummary2'
melliotab(x, ..., section = NULL)

melliotab(x, ...)

## Default S3 method:
melliotab(x, ..., section = NULL)

## S3 method for class ''NULL''
melliotab(x, ...)

## S3 method for class 'character'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'summaryDefault'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'table'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'data.frame'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'lm'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  conf.int = TRUE,
  conf.level = 0.95,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'glm'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  conf.int = TRUE,
  exponentiate = FALSE,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'aov'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  effect_size = TRUE,
  ...
)

## S3 method for class 'htest'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'matrix'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  decimals = 2L,
  p_decimals = 3L,
  diagonal = "dash",
  triangle = "all",
  ...
)

## S3 method for class 'lavaan'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  what = NULL,
  section = NULL,
  standardized = TRUE,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'FitDiff'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  section = NULL,
  what = NULL,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

## S3 method for class 'fa'
melliotab(
  x,
  style = "apa7",
  title = NULL,
  number = NULL,
  note = NULL,
  source = NULL,
  section = NULL,
  what = NULL,
  cut = 0,
  sort = FALSE,
  decimals = 2L,
  p_decimals = 3L,
  ...
)

Arguments

x

A data.frame, model object (lm, glm, aov, htest), or correlation matrix

style

Citation style: "apa7" or "ieee"

title

Table title

number

Table number (integer or character)

note

Table note text

source

Table source text

decimals

Decimal places for estimates/statistics (1-4)

p_decimals

Decimal places for p-values (2-4)

...

Additional arguments passed to methods

section

Optional section selector for multi-section tables. Examples include "fit", "loadings", "paths", "covariances", "defined", "reliability", or "modification_indices" for structural model payloads; "loadings", "variance", or "fit" for EFA; and "comparison", "fit", or "diff" for FitDiff objects.

conf.int

Include confidence intervals (default TRUE)

conf.level

Confidence level (default 0.95)

exponentiate

Show exponentiated coefficients (odds ratios for logistic)

effect_size

Include effect size (eta-squared) for ANOVA

diagonal

Diagonal display: "dash" (em-dash), "one" (keep 1.00), "blank"

triangle

Which triangle to show: "all", "lower", "upper"

what

Backward-compatible alias for section in methods that previously used what. Prefer section.

standardized

Include standardized estimates (default TRUE)

cut

Minimum absolute loading to display (default 0, show all). Loadings below this threshold are shown as blank cells.

sort

Sort items by their primary loading (default FALSE)

Value

A melliotab object

Supported inputs

melliotab() is intended for table output inside R. It supports plain data frames, matrices, base table objects, correlation matrices, common model objects, hypothesis-test objects, and payloads created by mellio_payload(). For objects that can produce several tables, call melliotab(x) once to see the available section choices, then request one explicitly, for example melliotab(fit, section = "loadings").

Common modifiers

The ⁠mt_*()⁠ helpers are optional table modifiers. They follow the same pattern as many R table packages: create a table once, then add formatting only where needed. Common helpers include mt_title(), mt_note(), mt_decimals(), mt_format_ci(), mt_remove_leading_zeros(), mt_sig_stars(), mt_spanner(), mt_indent(), and mt_section_title().

Significance stars are never added by default. Use mt_sig_stars() only when that convention is appropriate for your manuscript, course, or journal.

Examples

# From a data frame
df <- data.frame(
  Variable = c("Age", "Gender"),
  B = c(0.45, -1.23),
  SE = c(0.12, 0.34),
  t = c(3.75, -3.62),
  p = c(0.0003, 0.0004)
)
melliotab(df, style = "apa7", title = "Regression Results")

# From a linear model
model <- lm(Ozone ~ Temp + Wind, data = airquality)
melliotab(model, style = "apa7", title = "Predictors of ozone concentration")

# Compare multiple models side by side
m1 <- lm(Ozone ~ Temp, data = airquality)
m2 <- lm(Ozone ~ Temp + Wind, data = airquality)
m3 <- lm(Ozone ~ Temp + Wind + Solar.R, data = airquality)
melliotab(
  m1, m2, m3,
  labels = c("Step 1", "Step 2", "Step 3"),
  dep.var.labels = "Ozone concentration"
)

mellio documentation built on Aug. 30, 2026, 1:06 a.m.