Math and Stats: Exercises


7. Matrix rank. The rank of a matrix is the same as the rank of its transpose. In this exercise, you are given a matrix, X. Check its rank using the rankMatrix() function from the Matrix library. After that, transpose it using the t() function and check its rank.


X <- matrix(c(0,1,0,0,2,0,1,3,4), nrow=3, ncol=3) # Import the Matrix library. library(___) # Compute the rank of X. X_rank <- ___(X) # Transpose X. X_transpose <- ___ # Compute the rank of X_transpose. X_transpose_rank <- ___ # Import the Matrix library. library(Matrix) # Compute the rank of X. X_rank <- rankMatrix(X) # Transpose X. X_transpose <- t(X) # Compute the rank of X_transpose. X_transpose_rank <- rankMatrix(X_transpose) test_error() test_function("library", incorrect_msg="Did you import the correct library?") test_function("rankMatrix", incorrect_msg="Did you use `rankMatrix()` to compute the rank of `X`?") test_object("X_transpose", incorrect_msg="Did you compute the transpose of `X`?") success_msg("Excellent work. Given your findings, was X a full rank matrix?")
You can use the rankMatrix() function to check a matrix's rank.

Previous Exercise Next Exercise