Module 6: Matrix Operations in R
In this assignment, I practiced basic matrix operations in R, including addition, subtraction, and creating special matrices using the diag() function. These skills are important for understanding linear algebra concepts in data analysis and statistics. The topics are connected to matrix operations discussed in The Art of R Programming and good coding practices from R Packages. Question 1 : Consider A=matrix(c(2,0,1,3), ncol=2) and B=matrix(c(5,2,4,-1), ncol=2). a) Find A + B b) Find A - B First, I created two matrices: Matrix addition and subtraction are done element-by-element, as long as both matrices have the same dimensions. Question 2 : Using the diag() function to build a matrix of size 4 with the following values in the diagonal 4,1,2,3. Next, I created a 4×4 matrix with values 4, 1, 2, and 3 on the diagonal. The diag() function places the given va...