title: R: Error: `c_across()` must only be used inside dplyr verbs
body: <pre><code>library(tidyverse)
  nsource &lt;- 5
  mydata &lt;- structure(list(p1 = c(0.153603238035774, 0.251732841184133), 
                           p2 = c(0.0108935803858148, 0.12041117307058), 
                           p3 = c(0.712158280629968, 0.257556345715588), 
                           p4 = c(0.0529741150781822, 0.17690785400165), 
                           p5 = c(0.0703707858702605, 0.193391786028049)), 
                      row.names = 1:2, class = &quot;data.frame&quot;)
  
  mydata &lt;- mydata %&gt;% 
    rowwise %&gt;%
    mutate(P = sample(1:nsource, size = 1, replace = TRUE, 
                      prob = c_across(matches('^p\\d+$')))) %&gt;% 
    ungroup
  &gt; Error: `c_across()` must only be used inside dplyr verbs.
  </code></pre>
  <p>I have a dataset <code>mydata</code></p>
  <pre><code>         p1         p2        p3         p4         p5
  1 0.1536032 0.01089358 0.7121583 0.05297412 0.07037079
  2 0.2517328 0.12041117 0.2575563 0.17690785 0.19339179 
  </code></pre>
  <p>where each row contains 5 probabilities that sum up to one. I want to sample a number called &quot;P&quot; from 1:5 w/ probability p1:p5. However, running the above code gives me the error that &quot;<code>c_across()</code> must only be used inside dplyr verbs.&quot;</p>