title: How to alter values at a set frequency
body: <p>I am trying to find a way to edit my data. I have a data frame that consists of a location column and then 10 other columns that consist of &quot;Y&quot;s, &quot;N&quot;s, and &quot;-&quot;s.</p>
  <pre><code>structure(list(V1 = c(&quot;chr1:10150&quot;, &quot;chr1:10219&quot;, &quot;chr1:10230&quot;, 
  &quot;chr1:10427&quot;, &quot;chr1:10439&quot;, &quot;chr1:10440&quot;, &quot;chr1:10443&quot;, &quot;chr1:13459&quot;, 
  &quot;chr1:14397&quot;, &quot;chr1:15219&quot;), V2 = c(&quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;-&quot;, 
  &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;), V3 = c(&quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, 
  &quot;N&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;), V4 = c(&quot;N&quot;, &quot;Y&quot;, &quot;-&quot;, &quot;-&quot;, &quot;-&quot;, &quot;N&quot;, &quot;Y&quot;, 
  &quot;N&quot;, &quot;-&quot;, &quot;N&quot;), V5 = c(&quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, 
  &quot;Y&quot;, &quot;N&quot;), V6 = c(&quot;-&quot;, &quot;-&quot;, &quot;-&quot;, &quot;Y&quot;, &quot;-&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, 
  &quot;N&quot;), V7 = c(&quot;Y&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;
  ), V8 = c(&quot;N&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;-&quot;, &quot;-&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;), 
      V9 = c(&quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;-&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;-&quot;), 
      V10 = c(&quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;-&quot;, &quot;Y&quot;, &quot;Y&quot;, &quot;N&quot;), 
      V11 = c(&quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;, &quot;N&quot;)), row.names = c(NA, 
  -10L), class = &quot;data.frame&quot;)
  </code></pre>
  <p>I would like to find a way to randomly edit each row at a set frequency. What I mean by this is that, if I wanted to edit 0-5 values in a row, the code will possibly edit 3 values in row 1, then possibly 0 values in row 2, then possibly 5 values in row 3, and so on. The reason for doing this is because I need the data to somewhat match the original dataframe so I cant completely randomize things. I created a <code>case_when</code> function to try and do this myself but I am just not sure how to add some kind of frequency to the function. Your answer does not nee dot include the <code>case_when</code> function. I am adding it just in case it is helpful.</p>
  <pre><code>library(dplyr)
  df2 &lt;- df %&gt;% mutate_at(
    vars(-V1),
    funs(case_when(
      . == &quot;Y&quot; ~ &quot;-&quot;,
      . == &quot;N&quot; ~ &quot;Y&quot;,
      . == &quot;-&quot; ~ &quot;Y&quot;
      
    ))
  )
  </code></pre>