0
0
R Programmingprogramming~10 mins

Matrix multiplication (%*%) in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to multiply two matrices A and B.

R Programming
result <- A [1] B
Drag options to blanks, or click blank then click option'
A%*%
B*
C+
D%%
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which does element-wise multiplication instead of matrix multiplication.
Using + which adds matrices instead of multiplying.
2fill in blank
medium

Complete the code to multiply matrix M by vector v using matrix multiplication.

R Programming
result <- M [1] v
Drag options to blanks, or click blank then click option'
A%*%
B*
C/
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which does element-wise multiplication and gives wrong results.
Using + which adds instead of multiplies.
3fill in blank
hard

Fix the error in the code to correctly multiply matrices X and Y.

R Programming
Z <- X [1] Y
Drag options to blanks, or click blank then click option'
A+
B*
C%%
D%*%
Attempts:
3 left
💡 Hint
Common Mistakes
Using * which multiplies elements individually, not matrices.
Using + which adds matrices instead of multiplying.
4fill in blank
hard

Fill both blanks to create a matrix multiplication of A and B, then add matrix C.

R Programming
result <- (A [1] B) [2] C
Drag options to blanks, or click blank then click option'
A%*%
B+
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of %*% for matrix multiplication.
Using - instead of + for addition.
5fill in blank
hard

Fill all three blanks to multiply matrices X and Y, then subtract Z, and finally multiply by scalar s.

R Programming
final <- ((X [1] Y) [2] Z) [3] s
Drag options to blanks, or click blank then click option'
A%*%
B-
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of %*% for matrix multiplication.
Using + instead of - for subtraction.
Using %*% to multiply by scalar instead of *.