eigen() function in R Language is used to calculate eigenvalues and eigenvectors of a matrix. Eigenvalue is the factor by which a eigenvector is scaled.
Syntax: eigen(x)
Parameters:
x: Matrix
Example 1:
# R program to illustrate # Eigenvalues and eigenvectors of matrix # Create a 3x3 matrix A = matrix(c(1:9), 3, 3) cat("The 3x3 matrix:\n") print(A) # Calculating Eigenvalues and eigenvectors print(eigen(A)) |
chevron_right
filter_none
Output:
The 3x3 matrix:
[, 1] [, 2] [, 3]
[1, ] 1 4 7
[2, ] 2 5 8
[3, ] 3 6 9
eigen() decomposition
$values
[1] 1.611684e+01 -1.116844e+00 -5.700691e-16
$vectors
[, 1] [, 2] [, 3]
[1, ] -0.4645473 -0.8829060 0.4082483
[2, ] -0.5707955 -0.2395204 -0.8164966
[3, ] -0.6770438 0.4038651 0.4082483
Example 2:
# R program to illustrate # Eigenvalues and eigenvectors of matrix # Create a 3x3 matrix A = matrix(c(2, 3, 5, 1), 2, 2) A # Calculating Eigenvalues and eigenvectors print(eigen(A)) |
chevron_right
filter_none
Output:
[, 1] [, 2]
[1, ] 2 5
[2, ] 3 1
eigen() decomposition
$values
[1] 5.405125 -2.405125
$vectors
[, 1] [, 2]
[1, ] 0.8265324 -0.7503320
[2, ] 0.5628892 0.6610612
Recommended Posts:
- Check if the Object is a Matrix in R Programming - is.matrix() Function
- Convert a Data Frame into a Numeric Matrix in R Programming - data.matrix() Function
- Convert an Object into a Matrix in R Programming - as.matrix() Function
- Transform the Scaled Matrix to its Original Form in R Programming - Using Matrix Computations
- Find String Matches in a Vector or Matrix in R Programming - str_detect() Function
- Naming Rows and Columns of a Matrix in R Programming - rownames() and colnames() Function
- Getting the Modulus of the Determinant of a Matrix in R Programming - determinant() Function
- Return a Matrix with Lower Triangle as TRUE values in R Programming - lower.tri() Function
- Compute Choleski factorization of a Matrix in R Programming - chol() Function
- Get or Set Dimensions of a Matrix in R Programming - dim() Function
- Calculate the Sum of Matrix or Array columns in R Programming - colSums() Function
- Getting a Matrix of number of columns in R Programming - col() Function
- Calculate the Mean of each Column of a Matrix or Array in R Programming - colMeans() Function
- Calculate the cross-product of a Matrix in R Programming - crossprod() Function
- Calculate the cross-product of the Transpose of a Matrix in R Programming - tcrossprod() Function
- Compute the Sum of Rows of a Matrix or Array in R Programming - rowSums Function
- Getting the Determinant of the Matrix in R Programming - det() Function
- Construct a Diagonal Matrix in R Programming - diag() Function
- Perform Operations over Margins of an Array or Matrix in R Programming - apply() Function
- Getting a Matrix of number of rows in R Programming - row() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

