Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

umx_reorder

Reorder or drop variables from a correlation/covariance matrix.


Description

Reorder the variables in a correlation matrix. Can also remove one or more variables from a matrix using this function.

Usage

umx_reorder(old, newOrder, force = FALSE)

Arguments

old

a square matrix of correlation or covariances to reorder

newOrder

Variables you want in the order you wish to have

force

Just assume input is value (default = FALSE)

Value

- the re-ordered/resized matrix

References

- <https://github.com/tbates/umx>

See Also

Examples

oldMatrix = cov(mtcars)
umx_reorder(oldMatrix, newOrder = c("mpg", "cyl", "disp")) # first 3
umx_reorder(oldMatrix, newOrder = c("hp", "disp", "cyl")) # subset and reordered
umx_reorder(oldMatrix, "hp") # edge-case of just 1-var

umx

Structural Equation Modeling and Twin Modeling in R

v4.10.10
GPL-3
Authors
Timothy C. Bates [aut, cre] (<https://orcid.org/0000-0002-1153-9007>), Gillespie Nathan [wit], Michael Zakharin [wit], Brenton Wiernik [ctb], Joshua N. Pritikin [ctb], Michael C. Neale [ctb], Hermine Maes [ctb]
Initial release
2021-11-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.