Dichotomising Ordinal Categorical Variables When Variables Have Different Levels

Levels are an attribute of each variable object. As a consequence dichotomisation of each variable requires separate treatment. Those that share the same number of levels can be done with an appropriately composed function.

That is the immediate point—the more important point, though, is that the focus on the subsidiary question how obstructs visibility of the principal question what.

In what sense is a level of one variable comparable to the level of another? Suppose the variables are unisex garments and the levels represent sizes—XS, S, M, L, XL, XXL for one set and S, M, L for another. To put them on a common basis, some information contained in the six-level variables must be discarded by combining XS with S and XL and XXL with L. Alternatively, some information must be imputed to the other by creating levels with no instances.

A problem like this benefits from a concrete manifestation. See the FAQ: How to do a minimal reproducible example reprex for beginners. This will allow the general solution to be approached inductively rather than deductively and provide a principled basis on which to evaluate how well or poorly it performs against expectation.