I am trying to create a running average by group For example, i want to start creating the average of 2 continuous numbers when it starts with value of 170. However, if it first hits 170 and then >=200 then another >=200, i want to start average of those three. if not, just the average of two is fine. Here's an example ID value seq_id 1 150 1 1 190 2 1 205 3 1 210 4 1 150 5 2 169 1 2 175 2 2 150 3 2 144 4 3 200 1 3 201 2 3 199 3 Here's the output I am looking for: ID value seq_id avg 1 150 1 1 190 2 202 1 205 3 1 210 4 1 150 5 2 169 1 2 175 2 163 2 150 3 2 144 4 3 190 1 196 3 201 2 3 185 3 Thank you!
... View more