Reputation: 33293
I have a data frame like:
val1,val2
0, 0
0, 0
1, 1
1, 0
1, 1
What I want to do is do a cumulative count every time val1 and val2 disagrees
val1,val2, cum_count
0, 0, 1
0, 0, 2
1, 1, 3
1, 0, 3 <--- the value here doesn't changes as val1 and val2 disagrees
1, 1, 4
How do I do this in r?
Upvotes: 2
Views: 214