[R] How to number a subset consecutively from 1 to n?

Jens Bölte boelte at psy.uni-muenster.de
Fri Jul 10 15:27:08 CEST 2009


Hello,

I have a data frame of the following form

block trial dv
1 1 10
1 1 11
1 1  9
1 2 12
1 2  9
1 3 12
1 3 13
1 3 14
1 3 15
1 4 12
1 4 11
1 4 10
1 4  9
1 4 11

and need to number the rows consecutively in the following manner

block trial dv sequ
1 1 10 1
1 1 11 2
1 1  9 3
1 2 12 1
1 2  9 2
1 3 12 1
1 3 13 2
1 3 14 3
1 3 15 4
1 4 12 1
1 4 11 2
1 4 10 3
1 4  9 4
1 4 11 5

Any idea how to solve this problem? I tried but did not succeed :-(

Best Jens Bölte


More information about the R-help mailing list