title: How to rename rows with pattern in chunk using dplyr
body: <p>I have the following data frame (tibble):</p>
  
  <pre><code>library(tidyverse)
  lines&lt;-"
  A,foo,9394981
  B,bar,6826405
  C,qux,1074885
  D,gop,1493691   
  A,foo,100
  B,bar,200
  C,qux,300
  D,gop,400 
  "
  con &lt;- textConnection(lines)
  dat &lt;- read.csv(con,header=FALSE)
  close(con)
  dat &lt;- as.tibble(dat)
  dat
  </code></pre>
  
  <p>The values in <code>V2</code> comes in the chunk of four, i.e. always in <code>foo, bar, qux, gop</code>:</p>
  
  <pre><code>&gt; dat
  # A tibble: 8 × 3
        V1     V2      V3
    &lt;fctr&gt; &lt;fctr&gt;   &lt;dbl&gt;
  1      A    foo 9394981
  2      B    bar 6826405
  3      C    qux 1074885
  4      D    gop 1493691
  5      A    foo     100
  6      B    bar     200
  7      C    qux     300
  8      D    gop     400
  </code></pre>
  
  <p>How can I rename the row in <code>V2</code> so that it becomes like this:</p>
  
  <pre><code>  A    foo.w 9394981
    B    bar.x 6826405
    C    qux.y 1074885
    D    gop.z 1493691
    A    foo.w     100
    B    bar.x     200
    C    qux.y     300
    D    gop.z     400
  </code></pre>