utils_mat {metan} | R Documentation |
Utilities for handling with matrices
Description
These functions help users to make upper, lower, or symmetric matrices easily.
Usage
make_upper_tri(x, diag = NA)
make_lower_tri(x, diag = NA)
make_lower_upper(lower, upper, diag = NA)
make_sym(x, make = "upper", diag = NA)
tidy_sym(x, keep_diag = TRUE)
Arguments
x |
A matrix to apply the function. It must be a symmetric (square)
matrix in |
diag |
What show in the diagonal of the matrix. Default to |
lower |
A square matrix to fill the lower diagonal of the new matrix. |
upper |
A square matrix to fill the upper diagonal of the new matrix. |
make |
The triangular to built. Default is |
keep_diag |
Keep diagonal values in the tidy data frame? Defaults to
|
Details
-
make_upper_tri()
makes an upper triangular matrix using a symmetric matrix. -
make_lower_tri()
makes a lower triangular matrix using a symmetric matrix. -
make_sym()
makes a lower triangular matrix using a symmetric matrix. -
tidy_sym()
transform a symmetric matrix into tidy data frame.
Value
An upper, lower, or symmetric matrix, or a tidy data frame.
Author(s)
Tiago Olivoto tiagoolivoto@gmail.com
Examples
library(metan)
m <- cor(select_cols(data_ge2, 5:10))
make_upper_tri(m)
make_lower_tri(m)
make_lower_tri(m) %>%
make_sym(diag = 0)
tidy_sym(m)
tidy_sym(make_lower_tri(m))