eigenvectors_byname: Calculate eigenvectors of a matrix

View source: R/Unary.R

eigenvectors_bynameR Documentation

Calculate eigenvectors of a matrix

Description

Calculate the eigenvectors of a matrix or a list of matrices.

Usage

eigenvectors_byname(a)

Arguments

a

A matrix or list of matrices.

Details

This function pairs with eigenvalues_byname(); the first column of the resulting matrix is the eigenvector for the first eigenvalue reported by eigenvalues_byname(). The second column of the resulting matrix is the eigenvector for the second eigenvalue reported by eigenvalues_byname(). Etc.

Internally, this function uses base::eigen().

complete_rows_cols() is called prior to calculating the eigenvectors.

Value

A matrix whose columns are the eigenvectors of a.

Examples

m <- matrix(c( 4,  6, 10, 
               3, 10, 13, 
              -2, -6, -8), byrow = TRUE, nrow = 3, ncol = 3, 
            dimnames = list(c("p1", "p2", "p3"), c("p1", "p2", "p3")))
m
eigenvectors_byname(m)
eigenvectors_byname(list(m, 2*m))
DF <- tibble::tibble(m_col = list(m, 2*m)) %>% 
  dplyr::mutate(
    eigen_col = eigenvectors_byname(m_col)
  )
DF$eigen_col[[1]]
DF$eigen_col[[2]]

matsbyname documentation built on Oct. 19, 2023, 5:11 p.m.