title: Creating a function which mutates two column variables for columns with the same number ID
body: <p>I have a data frame:</p>
  <pre><code>ID &lt;- c(1:10)
  act1_144 &lt;- c(&quot;Bedroom&quot;, &quot;Bedroom&quot;, &quot;Bedroom&quot;, &quot;Lounge&quot;, &quot;Kitchen&quot;, &quot;Bedroom&quot;, &quot;Bedroom&quot;, &quot;Bedroom&quot;, &quot;Lounge&quot;, &quot;Kitchen&quot;)
  wher_144 &lt;- c(&quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;, &quot;Home&quot;)
  data &lt;- data.frame(ID, act1_144, wher_144)
  </code></pre>
  <p>and I am using mutate to make a new column based on the conditions of two other columns, e.g.</p>
  <pre><code>library(dplyr)
  data &lt;- data %&gt;%
      mutate(new_144 = case_when(
        act1_144 == &quot;Bedroom&quot; &amp; wher_144 == &quot;Home&quot; ~ &quot;Bedroom&quot;,
        act1_144 == &quot;Kitchen&quot; &amp; wher_144 == &quot;Home&quot; ~ &quot;Kitchen&quot;,
        act1_144 == &quot;Lounge&quot; &amp; wher_144 == &quot;Home&quot; ~ &quot;Lounge&quot;,
        act1_144 == &quot;Bathroom&quot; &amp; wher_144 == &quot;Home&quot; ~ &quot;Bathroom&quot;))
  </code></pre>
  <p>My real data frame has the variables act1_1 - act1_144 and wher_1 - wher_144. I'd like to put the above code into a function to loop through all matching combinations of act1_** and wher_**, as in the example above, without having to rerun the code 144 times.</p>
  <p>Is this possible? Thank you in advance</p>