makeTria: Reshapes an unordered covariance/correlation matrix into triangular shape
Description
Function is mainly used for eatAnalysis::wtdHetcor function from the
eatAnalysis package (https://github.com/beckerbenj/eatAnalysis/)
and the eatModel::q3FromRes function in the eatModel
package: Triangular covariance/correlation matrices are tidily reshaped.
Usage
makeTria (dfr)
Value
data frame.
Arguments
dfr
A data frame consisting of a row name column and a square matrix.
Details
covariance/correlation matrices which are inherently symmetrical are often displayed
in a space-saving manner by only showing the upper or lower triangular part, omitting the
symmetrical counterpart. In R, covariance/correlation matrices tend to be displayed with their
upper and lower halves. Whereas lower.tri and upper.tri
allows to replace upper or lower half with NAs, the triangular shape could then be lost if the
covariance/correlation matrix was provided in a long format and reshaped afterwards. makeTria
sorts rows and columns appropriately to provide triangular shape if redundant entries are replaced by
NA. Please note that the functions expects row names in the first column of the input data.frame.