Function to exclude (factor or interval) variables that have too many levels (as they may cause numerical problems), to change binary factors to 0-1 coding (as such factors might generate linear dependent variables) and to remove multiple intercepts.
cleanup(X, k = Inf)
A n times p data.frame with p fixed (or random) effects variables.
An integer defining the allowed maximum of levels in a factor covariate.
A n times (p-r) data.frame, with r being the number of variables with too many factors.