Module # 6 Doing math in R part 2
Module # 6 Doing math in R part 2 Answer the following questions and post your answer on your blog: 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 ncol = 2 means that numbers will be arranged into 2 columns in a 2x2 matrix. When performing A+B, it would look like this: (2+5) (1+4) = 7 5 (0+2) (3+(-1)) = 2 2 When performing A - B, it would look like this: ( 2 -5 ) ( 1 -4 ) = -3 -3 ( 0 -2 ) ( 3 -( -1 )) = -2 4 2. Using the diag() function to build a matrix of size 4 with the following values in the diagonal 4,1,2,3. With diag(c(4,1,2,3), we get a 4x4 matrix. These number would be placed in the diagonal elements. 3. Generate the following matrix: ## [,1] [,2] [,3] [,4] [,5] ## [1,] 3 1...