input sequential numbers without specific end in a data frame's column in r
问题 I would like to give a sequence of numbers to a new column to a data frame. But this sequence will repeat several times based on a value in another column. (i.e It starts from 1 until that specific value will be changed to other value). My problem is how to define the ending point for each sequence in r. A part of my data frame with the column "V2" which I intend to add: V1 V2(new added column with sequential numbers) 12 1 12 2 12 3 12 4 12 5 13 1 13 2 13 3 13 4 13 5 13 6 14 1 14 2 14 3 14 4