Questions
- What function is used to create a matrix in R?
- What is the output of
matrix(1:6, nrow = 2, ncol = 3)?
- Which function can bind matrices or vectors as columns to create a new matrix?
- If
mat <- matrix(1:9, nrow = 3), what does mat[2, 3] return?
- What will
dim(matrix(1:4, nrow = 2, ncol = 2)) return?
- Which function would you use to get the transpose of a matrix in R?
- If
mat <- matrix(1:4, nrow = 2), what will mat %*% mat return?
- What is the result of
ncol(matrix(1:6, nrow = 2))?
- Which of the following will convert a matrix to a vector?
- What does
diag(matrix(1:9, nrow = 3)) return?
- If
m <- matrix(1:12, nrow = 3, byrow = TRUE), what will m[2, ] return?
- What function would you use to get the inverse of a matrix in R?
- If
mat <- matrix(c(2, 4, 3, 8), nrow = 2), what is the output of apply(mat, 1, sum)?
- What will
nrow(matrix(1:10, nrow = 5)) return?
- Which of the following functions will extract the diagonal elements of a matrix?
- If
A is a matrix, what does t(A) %*% A represent?
- If
mat <- matrix(1:9, nrow = 3), what does mat[ , c(1, 3)] return?
- Which function reshapes a matrix into a vector by filling it column-wise?
- If
A <- matrix(1:4, nrow = 2) and B <- matrix(4:1, nrow = 2), what does A * B do?
- If
mat <- matrix(1:6, nrow = 2), what does colSums(mat) return?
- If
m <- matrix(1:9, nrow = 3), what is the output of m[ , -2]?
- What will
rowMeans(matrix(1:6, nrow = 2)) return?
- If
A <- matrix(1:4, nrow = 2), which command returns the determinant of A?
- What will
dim(matrix(1:12, ncol = 4)) return?
- If
mat <- matrix(1:12, nrow = 3), what does mat[mat > 5] return?
- Which function extracts only the lower triangular part of a matrix in R?
- If
mat <- matrix(1:9, nrow = 3), what does sum(mat) return?
- What does
is.matrix(c(1, 2, 3)) return?
- If
A <- matrix(c(1, 2, 3, 4), nrow = 2), which of the following commands will return TRUE if A is a square matrix?
- If
A <- matrix(1:9, nrow = 3), what does A[ , 3] return?