Saturday, June 23, 2018

How do you mulitply two matrices in R?

The Matrix package need not be loaded as it is readily accessible in Microsoft R Client version 3.3 (x64).

Here are two matrices whose product will be calculated.



Here is the result of matrix mulitplication of two 2x2 matrices showing the procedure
to calculate the product.

MatrixMultiply_2.png

Here is how it is calculated using R. The syntax is (matrix1)%*%(matrix2) where both matrices are square matrices.


MatrixMulitply_3.png

You can multiply a n x m matrix with m x n matrix as shown here to get a n x n matrix.


MatrixMulitply_3.png
Here is an online matrix multiplier:

https://www.mathsisfun.com/algebra/matrix-calculator.html

No comments: