Q:

How do I identify rows/columns that does not increase rank of matrix in R?

Suppose I have a symmetric, positive semidefinite matrix A of dimension n x n. The rank of A is d < n, and I want to find a set of indices of length d such that A[indices, indices] has rank d. For example, if
A <- structure(c(3, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(4L, 4L))

then I would like to identify one of the sets of indices c(1, 2, 3) or c(1, 2, 4).
I can do this by brute force going through all combinations of rows and columns, but my guess is that there exist much more elegant and efficient methods for doing this. 

A:

You can use the QR decomposition, qr
q <- qr(A)
q$pivot[seq(q$rank)]
# [1] 1 2 3

A[,q$pivot[seq(q$rank)]]
#      [,1] [,2] [,3]
# [1,]    3    2    1
# [2,]    2    2    1
# [3,]    1    1    1
# [4,]    1    1    1

These resulting columns should be linearly independent.

