title: Cumulative Count Paste
body: <p>I have this dataset:</p>
  
  <pre><code>  ID Set Type Count
  1  1   1    A    NA
  2  2   1    R    NA
  3  3   1    R    NA
  4  4   1    U    NA
  5  5   1    U    NA
  6  6   1    U    NA
  7  7   2    A    NA
  8  8   3    R    NA
  9  9   3    R    NA
  </code></pre>
  
  <p>As <code>dputs</code>:</p>
  
  <pre><code>mystart &lt;- structure(list(ID = 1:9, Set = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
  3L, 3L), Type = structure(c(1L, 2L, 2L, 3L, 3L, 3L, 1L, 2L, 2L
  ), .Label = c("A", "R", "U"), class = "factor"), Count = c(NA, 
  NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c("ID", "Set", "Type", 
  "Count"), class = "data.frame", row.names = c(NA, -9L))
  </code></pre>
  
  <p>By using <code>dplyr</code> package how can I obtain this:</p>
  
  <pre><code>  ID Set Type  Count
  1  1   1    A     A1
  2  2   1    R   A1R1
  3  3   1    R   A1R2
  4  4   1    U A1R2U1
  5  5   1    U A1R2U2
  6  6   1    U A1R2U3
  7  7   2    A     A1
  8  8   3    R     R1
  9  9   3    R     R2
  </code></pre>
  
  <p>Again <code>dputs</code>:</p>
  
  <pre><code>myend &lt;- structure(list(ID = 1:9, Set = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
  3L, 3L), Type = structure(c(1L, 2L, 2L, 3L, 3L, 3L, 1L, 2L, 2L
  ), .Label = c("A", "R", "U"), class = "factor"), Count = structure(c(1L, 
  2L, 3L, 4L, 5L, 6L, 1L, 7L, 8L), .Label = c("A1", "A1R1", "A1R2", 
  "A1R2U1", "A1R2U2", "A1R2U3", "R1", "R2"), class = "factor")), .Names = c("ID", 
  "Set", "Type", "Count"), class = "data.frame", row.names = c(NA, 
  -9L))
  </code></pre>
  
  <p><hr>
  In short, I want to count the observations of the column <code>"type"</code> within column <code>"set"</code> and print this <code>count(text)</code> cumulatively.</p>
  
  <p>Examining similar posts, I got closely to this:</p>
  
  <pre><code>myend &lt;- structure(list(ID = 1:9, Set = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
  3L, 3L), Type = structure(c(1L, 2L, 2L, 3L, 3L, 3L, 1L, 2L, 2L
  ), .Label = c("A", "R", "U"), class = "factor"), Count = c(1L, 
  1L, 2L, 1L, 2L, 3L, 1L, 1L, 2L)), .Names = c("ID", "Set", "Type", 
  "Count"), class = "data.frame", row.names = c(NA, -9L))
  </code></pre>
  
  <p>With the code:</p>
  
  <pre><code>library(dplyr)
  myend &lt;- read.table("mydata.txt", header=TRUE, fill=TRUE)
      myend %&gt;%
      group_by(Set, Type) %&gt;%
      mutate(Count = seq(n())) %&gt;%
      ungroup(myend)
  </code></pre>
  
  <p>Thank you very much for your help,</p>