I have a data like this:
f x
A 1.1
A 2.2
A 3.3
B 3.5
B 3.7
B 3.9
B 4.1
B 4.5
A 5.1
A 5.2
C 5.4
C 5.5
C 6.1
B 6.2
B 6.3
I would like to average x over continuous blocks of f, to get this, similar to tapply(...,mean), but aware of the fact that it shouldn’t mix separated blocks and in original order:
f x
A 2.2
B 3.94
A 5.15
C 5.67
B 6.25
rleis one possibility :It gives you the runs and the values, so you can use both.