detect rank deficient in r
# Step 1: Create a matrix (replace this with your actual data)
A <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
# Step 2: Use the 'qr' function to compute the QR decomposition
qr_decomposition <- qr(A)
# Step 3: Extract the rank of the matrix from the QR decomposition
rank_A <- qr_decomposition$rank
# Step 4: Check if the matrix is rank deficient
if (rank_A < min(dim(A))) {
print("Matrix is rank deficient.")
} else {
print("Matrix is full rank.")
}