Skip to contents

Build APA-style table output using base R structures

Usage

apa_table(
  x,
  which = NULL,
  diagnostics = NULL,
  digits = 2,
  caption = NULL,
  note = NULL,
  bias_results = NULL,
  context = list(),
  whexact = FALSE,
  branch = c("apa", "facets")
)

Arguments

x

A data.frame, mfrm_fit, diagnostics list, or bias-result list.

which

Optional table selector when x has multiple tables.

diagnostics

Optional diagnostics from diagnose_mfrm() (used when x is mfrm_fit and which targets diagnostics tables).

digits

Number of rounding digits for numeric columns.

caption

Optional caption text.

note

Optional note text.

bias_results

Optional output from estimate_bias() used when auto-generating APA metadata for fit-based tables.

context

Optional context list forwarded when auto-generating APA metadata for fit-based tables.

whexact

Logical forwarded to APA metadata helpers.

branch

Output branch: "apa" for manuscript-oriented labels, "facets" for FACETS-aligned labels.

Value

A list of class apa_table with fields:

  • table (data.frame)

  • which

  • caption

  • note

  • digits

  • branch, style

Details

This helper avoids styling dependencies and returns a reproducible base data.frame plus metadata.

Supported which values:

  • For mfrm_fit: "summary", "person", "facets", "steps"

  • For diagnostics list: "overall_fit", "measures", "fit", "reliability", "facets_chisq", "bias", "interactions", "interrater_summary", "interrater_pairs", "obs"

  • For bias-result list: "table", "summary", "chi_sq"

Interpreting output

  • table: plain data.frame ready for export or further formatting.

  • which: source component that produced the table.

  • caption/note: manuscript-oriented metadata stored with the table.

Typical workflow

  1. Build table object with apa_table(...).

  2. Inspect quickly with summary(tbl).

  3. Render base preview via plot(tbl, ...) or export tbl$table.

Examples

toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score", method = "JML", maxit = 25)
tbl <- apa_table(fit, which = "summary", caption = "Model summary", note = "Toy example")
tbl_facets <- apa_table(fit, which = "summary", branch = "facets")
summary(tbl)
#> APA Table Summary
#>  Branch Style   Which Rows Columns NumericColumns MissingValues
#>     apa   apa summary    1      11              8             0
#> 
#> Caption
#>  - Model summary
#> 
#> Note
#>  - Toy example
#> 
#> Numeric profile
#>      Column N    Mean SD     Min     Max
#>         AIC 1 1755.90 NA 1755.90 1755.90
#>         BIC 1 2020.59 NA 2020.59 2020.59
#>  Categories 1    4.00 NA    4.00    4.00
#>      Facets 1    2.00 NA    2.00    2.00
#>  Iterations 1   67.00 NA   67.00   67.00
#>      LogLik 1 -820.95 NA -820.95 -820.95
#>           N 1  768.00 NA  768.00  768.00
#>     Persons 1   48.00 NA   48.00   48.00
p <- plot(tbl, draw = FALSE)
p_facets <- plot(tbl_facets, type = "numeric_profile", draw = FALSE)
if (interactive()) {
  plot(
    tbl,
    type = "numeric_profile",
    main = "APA Table Numeric Profile (Customized)",
    palette = c(numeric_profile = "#2b8cbe", grid = "#d9d9d9"),
    label_angle = 45
  )
}
class(tbl)
#> [1] "apa_table_apa" "apa_table"     "list"         
tbl$note
#> [1] "Toy example"