[This article was first published on Analysis with R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Matrix manipulation in R are very useful in Linear Algebra. Below are lists of common yet important functions in dealing operations with matrices:Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
- Transpose – t
- Multiplication – %*%
- Determinant – det
- Inverse – solve, or ginv of MASS library
- Eigenvalues and Eigenvectors – eigen
Transposing these, simply use t
Now multiplying these two matrices, that would be
For the determinant, we have
Taking the inverse of matrix1 is achieved by solve or ginv R functions. Note that ginv is in MASS package,
And finally, for eigenvalues and eigenvectors simply use eigen
The output above returns the $values, which is the eigenvalues, and $vectors, the eigenvectors.
More about matrix here.
To leave a comment for the author, please follow the link and comment on their blog: Analysis with R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.