0
0
R Programmingprogramming~5 mins

Matrix arithmetic in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a matrix in R?
A matrix in R is a two-dimensional array that holds elements of the same type arranged in rows and columns.
Click to reveal answer
beginner
How do you create a 2x2 matrix with numbers 1 to 4 in R?
Use the matrix() function: <br> matrix(1:4, nrow=2, ncol=2)
Click to reveal answer
beginner
What operator is used for matrix multiplication in R?
The %*% operator is used for matrix multiplication in R.
Click to reveal answer
beginner
What happens when you add two matrices in R?
Adding two matrices adds their corresponding elements to create a new matrix of the same size.
Click to reveal answer
beginner
How do you multiply each element of a matrix by a number in R?
You multiply the matrix by the number using the * operator, which multiplies each element individually.
Click to reveal answer
Which function creates a matrix in R?
Amatrix()
Barray()
Clist()
Ddata.frame()
What does the operator %*% do in R?
AElement-wise multiplication
BAddition
CMatrix multiplication
DTranspose
If A and B are matrices of the same size, what does A + B do?
AConcatenates A and B
BMultiplies A and B
CSubtracts B from A
DAdds corresponding elements of A and B
How do you multiply each element of a matrix by 3 in R?
Amatrix %*% 3
Bmatrix * 3
Cmatrix + 3
Dmultiply(matrix, 3)
What is the result of matrix(1:4, nrow=2, ncol=2)?
A[[1,3],[2,4]]
B[[1,2],[3,4]]
C[[1,4],[2,3]]
D[[4,3],[2,1]]
Explain how to perform matrix multiplication in R and how it differs from element-wise multiplication.
Think about how you multiply rows by columns versus multiplying each element separately.
You got /4 concepts.
    Describe how to create a matrix in R and how to add two matrices together.
    Start with creating the matrix, then explain addition.
    You got /4 concepts.