Multiple Choices: Matrices

Questions

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