# How to check for singular columns

I'm trying to run a model in R, but it's far of a larger process where the input matrix isn't the same each time. There are occasions where I get an error to say that the matrix contains singular columns. How can I check which these are, and more importantly, how can I remove them prior to the modelling stage?

• lm automatically identifies such columns. The problem is that they are not unique: there's no such thing as "a" singular column; all you can tell is whether various subsets of columns are linearly independent or not. You probably would prefer to ask the question addressed at stats.stackexchange.com/questions/173665. At stats.stackexchange.com/a/366993/919 I answer the question you have asked: namely, by showing how to find all such sets of columns.
– whuber
Jul 27 '21 at 16:14