Remove columns which have zero occurences in a factor level

I have a column of type factor in my data whose summary looks as follows

    0     1  <NA>
31557     0     0

As you can see, there are only three levels for this column and two of them have zero occurrences, which means it’s basically just one factor level.

The trouble with this is that, when I do certain operations like regression, I get an error which says,

contrasts can be applied only to factors with 2 or more levels

How can I remove this column which have all their occurrences in just one of the factor levels?

Source: New Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.