For you rWizards out there this is surely trivial. My problem:

I have measured something ("value") under several blocked conditions (f1, f2, …), and each condition combination is recorded twice. So I have now (simplified) a data.frame like so

ID f1 f2 value
1 a C 0.12
1 a D 0.34
1 b C 0.56
1 b D 0.78
1 a C 0.89
1 a D 0.91
1 b C 0.12
1 b D 0.23 … repeat similarly for all other IDs

and I want to add a "repeat" or "run" column (effectively a new factor) like so:

ID f1 f2 run value
1 a C 1 0.12
1 a D 1 …
1 b C 1 …
1 b D 1
1 a C 2
1 a D 2
1 b C 2
1 b D 2 …

I could do this in a loop through all rows, making a subset of conditions, and set "run" to 2 for the second one. I'm sure there's an easier way.

Thanks already for your kind help!

Best, Michael