Matrices in R
This section provides details on the construction and manipulation of these objects, including matrix facilities that are different from typical element-wise operations.
Matrices
Eigenvalues and eigenvectors
The function eigen(Sm) calculates the eigenvalues and
eigenvectors of a symmetric matrix Sm. The result of this
function is a list of two components named values and
vectors. The assignment
> ev <- eigen(Sm)
will assign this list to ev. Then ev$val is the vector of
eigenvalues of Sm and ev$vec is the matrix of
corresponding eigenvectors. Had we only needed the eigenvalues we could
have used the assignment:
> evals <- eigen(Sm)$values
evals now holds the vector of eigenvalues and the second
component is discarded. If the expression
> eigen(Sm)
is used by itself as a command the two components are printed, with their names. For large matrices it is better to avoid computing the eigenvectors if they are not needed by using the expression
> evals <- eigen(Sm, only.values = TRUE)$values