% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print.efa_loadings.R
\name{print.efa_loadings}
\alias{print.efa_loadings}
\alias{format.efa_loadings}
\title{Print a loading matrix}
\usage{
\method{print}{efa_loadings}(x, ...)

\method{format}{efa_loadings}(
  x,
  cutoff = 0.3,
  digits = 3,
  max_name_length = 10,
  h2 = NULL,
  color = TRUE,
  name_style = c("truncate", "abbreviate", "full"),
  max_factor_name_length = NULL,
  max_factors_per_block = NULL,
  sort_loadings = c("none", "primary", "clustered"),
  legend = FALSE,
  ...
)
}
\arguments{
\item{x}{a loading matrix of class \code{efa_loadings} (or the legacy \code{LOADINGS}).}

\item{...}{additional arguments passed to print or format}

\item{cutoff}{numeric. The value at or above which loadings are emphasized;
default is .3.}

\item{digits}{numeric. Passed to \code{\link[base:Round]{round}}. Number of digits
to round the loadings to (default is 3).}

\item{max_name_length}{numeric. The maximum length of the variable names to
display. Everything beyond this will be cut from the right unless
\code{name_style = "abbreviate"} or \code{name_style = "full"} is used. Cutting never
leaves two variables sharing a row label: if it would (as for items with a
long common prefix), the names are abbreviated instead, and numbered if
needed.}

\item{h2}{numeric. Vector of communalities to print. If named and \code{x}
has row names, names are used to align communalities to rows.}

\item{color}{logical. Whether to apply console styling using \pkg{cli}.
Default is \code{TRUE}.}

\item{name_style}{character. How to shorten variable names longer than
\code{max_name_length}. \code{"truncate"} cuts names from the right,
\code{"abbreviate"} uses \code{\link[base:abbreviate]{base::abbreviate()}}, and
\code{"full"} prints full names.}

\item{max_factor_name_length}{numeric or \code{NULL}. Optional maximum length
of factor names. If \code{NULL}, factor names are not shortened.}

\item{max_factors_per_block}{numeric or \code{NULL}. Maximum number of factor
columns to print per block. If \code{NULL}, the number is chosen from the
console width.}

\item{sort_loadings}{character. Optional row sorting. \code{"none"} preserves
the input order, \code{"primary"} groups rows by the factor with the largest
absolute loading, and \code{"clustered"} additionally sorts within each
factor by the size of the primary loading.}

\item{legend}{logical. Whether to append a short explanation of the styling.
Default is \code{FALSE} for standalone loading matrices. The legend is only printed
when the styling it describes is actually rendered (\code{color = TRUE} and a
colour-capable console); in plain output it is omitted and this argument has
no effect.}
}
\value{
\code{print()} returns its argument \code{x} invisibly; it is
\code{cat(format(x, ...), sep = "\\n")} followed by a blank line for console
spacing. \code{format()} returns a character vector with the table lines (styled
to the active console theme; plain when colours are disabled).
}
\description{
Print a loading matrix
}
\details{
The method prints a loading matrix in a compact, console-oriented table.
Loadings with absolute value greater than or equal to \code{cutoff} are emphasized,
smaller loadings are de-emphasized, and Heywood-relevant communality/
uniqueness values are marked when \code{h2} is supplied. Long variable names can
be truncated, abbreviated, or printed in full. If the matrix has many factor
columns, the table is split into column blocks so that the output remains
readable in narrower consoles.

If \code{h2} is named and \code{x} has row names, \code{h2} is matched to the row names of
\code{x} before any optional row sorting is applied. If \code{x} has no row names, a
named \code{h2} vector is used in the supplied order.
}
\examples{
EFAtools_PAF <- efa_fit(test_models$baseline$cormat, n_factors = 3, N = 500,
                        estimator = "PAF", rotation = "promax")
EFAtools_PAF

# format() returns the same lines as a character vector:
writeLines(format(EFAtools_PAF$rot_loadings))

}
