title: How to find first element of a group that fulfill a condition
body: <pre><code>structure(list(group = c(17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 
  19L, 19L, 20L, 20L, 20L, 21L, 21L, 22L, 23L, 24L, 25L, 25L, 25L, 
  26L, 27L, 27L, 27L, 28L), var = c(74L, 49L, 1L, 74L, 1L, 49L, 
  61L, 49L, 1L, 5L, 5L, 1L, 44L, 44L, 12L, 13L, 5L, 5L, 1L, 1L, 
  4L, 4L, 1L, 1L, 1L, 49L), first = c(0, 0, 1, 0, 1, 0, 0, 0, 1, 
  0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)), .Names = c("group", 
  "var", "first"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, 
  -26L))
  </code></pre>
  
  <p>With the data from the first two column I would like to create a third column (called <code>first</code>) where <code>first == 1</code> only when <code>var == 1</code> for the first time in a group. In other words I would like to mark first elements within <code>group</code> that fullfil <code>var == 1</code>. How can I do that in <code>dplyr</code>? Certainly <code>group_by</code> should be used but what next?</p>