I am trying to re-factor across all column factors in a data frame to reduce the number of factor levels. Example is in my case, after I removed about 50% of rows in my data frame, a lot of columns have values in their factor levels that no longer exist, and I want to remove them. The data frame contains quite a lot of columns which are factors, so re-factoring them one at a time was getting tedious for me.
There's another question in SO called refactor data.frame column values but it doesn't address my question, so I thought I'll put in the question here as reference.