title: Getting row index where a new value starts
body: <p>I have a simple <code>data.frame</code> as created below. I want to get all the row indices where a new <code>origin</code> starts. In this case it would be 1, 5, and 8. Is there a way to do this without looping? </p>
  
  <pre><code>df &lt;- data.frame(origin=c(rep('2016-01-01', 4), rep('2016-02-01',3), rep('2016-03-01',2)), 
    date=c('2016-01-01','2016-02-01','2016-03-01','2016-04-01','2016-02-01','2016-03-01','2016-04-01','2016-03-01','2016-04-01'),
    val=rnorm(9))
  
  df$date &lt;- as.Date(df$date)
  df$origin &lt;- as.Date(df$origin)
  
  df
        origin       date        val
  1 2016-01-01 2016-01-01 -2.0856573
  2 2016-01-01 2016-02-01 -0.5930160
  3 2016-01-01 2016-03-01  0.5370460
  4 2016-01-01 2016-04-01  1.5539720
  5 2016-02-01 2016-02-01  0.4866211
  6 2016-02-01 2016-03-01 -0.1443780
  7 2016-02-01 2016-04-01 -0.9286197
  8 2016-03-01 2016-03-01 -0.6311255
  9 2016-03-01 2016-04-01  1.1667005
  </code></pre>