I am trying to impute incremental values for each 5 rows of the data frame. I am new to R and not sure how to achieve this.
Input data:
state Value
a 1
b 2
a 3
c 4
a 5
e 6
f 7
w 8
f 9
s 10
e 11
r 12
s 13
s 14
Desired Output:
state Value Increment
a 1 1
b 2 1
a 3 1
c 4 1
a 5 1
e 6 2
f 7 2
w 8 2
f 9 2
s 10 2
e 11 3
r 12 3
s 13 3
s 14 3