I am trying to add a column to a data frame that will sequentially count the number of "events" where my "state" variable trasitions according to the fol