% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-reports.R
\name{apa_table}
\alias{apa_table}
\title{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{
\item{x}{A data.frame, \code{mfrm_fit}, \code{summary()} output supported by
\code{\link[=build_summary_table_bundle]{build_summary_table_bundle()}}, an \code{mfrm_summary_table_bundle}, diagnostics
list, or bias-result list.}

\item{which}{Optional table selector when \code{x} has multiple tables.}

\item{diagnostics}{Optional diagnostics from \code{\link[=diagnose_mfrm]{diagnose_mfrm()}} (used when
\code{x} is \code{mfrm_fit} and \code{which} targets diagnostics tables).}

\item{digits}{Number of rounding digits for numeric columns.}

\item{caption}{Optional caption text.}

\item{note}{Optional note text.}

\item{bias_results}{Optional output from \code{\link[=estimate_bias]{estimate_bias()}} used when
auto-generating APA metadata for fit-based tables.}

\item{context}{Optional context list forwarded when auto-generating APA
metadata for fit-based tables.}

\item{whexact}{Logical forwarded to APA metadata helpers.}

\item{branch}{Output branch:
\code{"apa"} for manuscript-oriented labels, \code{"facets"} for FACETS-aligned labels.}
}
\value{
A list of class \code{apa_table} with fields:
\itemize{
\item \code{table} (\code{data.frame})
\item \code{which}
\item \code{caption}
\item \code{note}
\item \code{digits}
\item \code{branch}, \code{style}
}
}
\description{
Build APA-style table output using base R structures
}
\details{
This helper avoids styling dependencies and returns a reproducible base
\code{data.frame} plus metadata.

Supported \code{which} values:
\itemize{
\item For \code{mfrm_fit}: \code{"summary"}, \code{"person"}, \code{"facets"}, \code{"steps"}
\item For \code{summary()} outputs or \code{mfrm_summary_table_bundle}:
names listed in \code{build_summary_table_bundle(x)$table_index}
\item For diagnostics list: \code{"overall_fit"}, \code{"measures"}, \code{"fit"},
\code{"reliability"}, \code{"facets_chisq"}, \code{"bias"}, \code{"interactions"},
\code{"interrater_summary"}, \code{"interrater_pairs"}, \code{"obs"}
\item For bias-result list: \code{"table"}, \code{"summary"}, \code{"chi_sq"}
}
}
\section{Interpreting output}{

\itemize{
\item \code{table}: plain data.frame ready for export or further formatting.
\item \code{which}: source component that produced the table.
\item \code{caption}/\code{note}: manuscript-oriented metadata stored with the table.
}
}

\section{Typical workflow}{

\enumerate{
\item Build table object with \code{apa_table(...)}.
\item Inspect quickly with \code{summary(tbl)}.
\item Render base preview via \code{plot(tbl, ...)} or export \code{tbl$table}.
}
}

\examples{
toy <- load_mfrmr_data("example_core")
fit <- fit_mfrm(toy, "Person", c("Rater", "Criterion"), "Score", method = "JML", maxit = 30)
tbl <- apa_table(fit, which = "summary", caption = "Model summary", note = "Toy example")
tbl_facets <- apa_table(fit, which = "summary", branch = "facets")
fit_bundle <- build_summary_table_bundle(summary(fit))
tbl_from_summary <- apa_table(fit_bundle, which = "facet_overview")
summary(tbl)
p <- plot(tbl, draw = FALSE)
p_facets <- plot(tbl_facets, type = "numeric_profile", draw = FALSE)
p$data$plot
p_facets$data$plot
if (interactive()) {
  plot(
    tbl,
    type = "numeric_profile",
    main = "APA Table Numeric Profile (Customized)",
    palette = c(numeric_profile = "#2b8cbe", grid = "#d9d9d9"),
    label_angle = 45
  )
}
tbl$note
}
\seealso{
\code{\link[=fit_mfrm]{fit_mfrm()}}, \code{\link[=diagnose_mfrm]{diagnose_mfrm()}}, \code{\link[=build_apa_outputs]{build_apa_outputs()}},
\code{\link[=reporting_checklist]{reporting_checklist()}}, \link{mfrmr_reporting_and_apa}
}
