title: How to collapse categories or recategorize variables?
body: <p>In R, I have 600,000 categorical variables, each of which is classified as &quot;0&quot;, &quot;1&quot;, or &quot;2&quot;.</p>
  <p>What I would like to do is collapse &quot;1&quot; and &quot;2&quot; and leave &quot;0&quot; by itself, such that after re-categorizing &quot;0&quot; = &quot;0&quot;; &quot;1&quot; = &quot;1&quot; and &quot;2&quot; = &quot;1&quot;. In the end I only want &quot;0&quot; and &quot;1&quot; as categories for each of the variables.</p>
  <p>Also, if possible, I would rather not create 600,000 new variables, if I can replace the existing variables with the new values that would be great!</p>
  <p>What would be the best way to do this?</p>