0
0
R Programmingprogramming~10 mins

Why matrices handle tabular math in R Programming - Test Your Understanding

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

Complete the code to create a 2x2 matrix with numbers 1 to 4.

R Programming
mat <- matrix([1], nrow = 2, ncol = 2)
Drag options to blanks, or click blank then click option'
Ac(1, 2, 3)
B1:4
Cseq(1, 5)
Dc(1, 2)
Attempts:
3 left
💡 Hint
Common Mistakes
Using a vector with fewer or more elements than needed.
2fill in blank
medium

Complete the code to access the element in the first row and second column of the matrix.

R Programming
value <- mat[[1] , 2]
Drag options to blanks, or click blank then click option'
A0
B2
C1
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as an index, which is invalid in R.
3fill in blank
hard

Fix the error in the code to multiply two matrices correctly.

R Programming
result <- mat1 [1] mat2
Drag options to blanks, or click blank then click option'
A%*%
B*
C%
D%%
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of %*% causes element-wise multiplication, not matrix multiplication.
4fill in blank
hard

Fill both blanks to create a matrix with 3 rows and 2 columns using numbers 1 to 6.

R Programming
mat <- matrix([1], nrow = [2], ncol = 2)
Drag options to blanks, or click blank then click option'
A1:6
B3
C2
Dc(1, 2, 3)
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong number of values or wrong row count.
5fill in blank
hard

Fill all three blanks to create a matrix from vector 'v', with 2 rows, 3 columns, and fill by row.

R Programming
mat <- matrix([1], nrow = [2], ncol = [3], byrow = TRUE)
Drag options to blanks, or click blank then click option'
Av
B2
C3
DFALSE
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing nrow and ncol values or forgetting to set byrow.