title: How to perform conditional mutate on unspecified columns (e.g. matching regex)?
body: <p>I have a nested data.frame - <code>df_nested</code>, there one of column contains <code>df</code>:</p>
  <pre><code>df &lt;- tibble(ID_Value = 1:8,
               xyz001 = c(&quot;text4&quot;, NA, NA, NA, NA, NA, NA, &quot;text2&quot;), 
               xyz002 = c(NA, NA, NA, &quot;text3&quot;, &quot;text1&quot;, NA, NA, NA),
               xyz003 = c(NA, &quot;text1&quot;, NA, NA, &quot;text2&quot;, NA, &quot;text2&quot;, NA)) 
  </code></pre>
  <p>I want to find a way, how to mutate this df, on these requirements:</p>
  <ol>
  <li><code>mutate(across(matches(&quot;\\d&quot;)</code></li>
  <li>there are 4 cases - 4 levels by priority. text4 &lt;- text3 &lt;- text2 &lt;- text1:
  I need to find and keep column values containing only the highest level text. e.g. if column contains text4, I want to remove text3, text2, text1 and replace them to NA.
  If it contains multiple highest order text, we should keep all these values (e.g. column xyz003).</li>
  <li>how to apply these conditions not specifying column name, because there can be any number in column name.</li>
  <li>if column contains all NAs, do nothing.</li>
  </ol>
  <p>my attempt:</p>
  <pre><code>df_nested &lt;- df_nested %&gt;%
      mutate(df = map(data, ~.x %&gt;%
         mutate(across(matches(&quot;\\dd&quot;), function (x) {
                        conditions (ifelse, case_when or other)
                        ...}
  </code></pre>
  <p>Also, should we better use <code>across()</code>, or is <code>vars()</code> still a good way to do it as well?
  Thank you in advance.</p>
  <p><strong>Expected Output</strong></p>
  <pre><code>df &lt;- tibble(ID_Value = 1:8,
               xyz001 = c(&quot;text4&quot;, NA, NA, NA, NA, NA, NA, NA), 
               xyz002 = c(NA, NA, NA, &quot;text3&quot;, NA, NA, NA, NA),
               xyz003 = c(NA, NA, NA, NA, &quot;text2&quot;, NA, &quot;text2&quot;, NA))
  </code></pre>