% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reflect_fa.R
\name{reflect_fa}
\alias{reflect_fa}
\title{Reflect the signs of the columns of the factor pattern matrix
so that the number of positive loadings is larger than the negative ones.}
\usage{
reflect_fa(A, sortcols = 0, unclass = 0)
}
\arguments{
\item{A}{Factor Pattern matrix or an object with $loadings.}

\item{sortcols}{= 1 to sort factors (columns of A) according to
factor contributions.}

\item{unclass}{= 1 to unclass the result}

\item{print}{= 1 to print the result}
}
\value{
A list of \cr
loadings = reordered loadings matrix \cr
col_order = sort order of the cols \cr
sign = a vector indicating if the signs were preserved or not
}
\description{
Reflect the signs of the columns of the factor pattern matrix
so that the number of positive loadings is larger than the negative ones.
}
\details{
First, if sortcols == 1, the columns of \code{A} are reordered
according to the magnitude of \code{diag(t(A)\%*\%A)}. \cr
Then, for each column of \code{A},
the sign will be reflected if the number of negative loadings is
greater than the positive ones.
}
\examples{
set.seed(1701)
n <- 20; ndim <- 4
A0 <- matrix(runif(n*ndim),n,ndim)
dimnames(A0)=list( paste("v",1:n,sep=""),paste("f",1:ndim,sep=""))
A0v <- varimax(A0)$loadings
A0v <- A0v*matrix(sample(c(-1,1,1),n*ndim,replace=TRUE),n,ndim)
A0v[,3:4] <- -A0v[,3:4]

A0vs <- reflect_fa(A0v)$loadings
Print(A0v,A0vs, fmt="6.3")

A0vsc <- reflect_fa(A0v, sortcol=1)$loadings
Print(A0v,A0vsc, fmt="6.3")

# attributes
print(reflect_fa(A0v)$loadings)
print(reflect_fa(A0v, unclass=1)$loadings)

}
