I have This data frame, I would like to browse the array, when the condition is 1, I stop and take the maximum of value. For exemple, I take the max(16,8)= 8 ; max(6,10,9,8)=10.
| Identifiant | Value | Condition |
|---|---|---|
| ID1 | 16 | 1 |
| ID2 | 8 | 1 |
| ID3 | 4 | 0 |
| ID4 | 5 | 0 |
| ID5 | 6 | 1 |
| ID6 | 10 | 1 |
| ID7 | 9 | 1 |
| ID8 | 8 | 1 |
| ID9 | 9 | 0 |
| ID10 | 11 | 0 |
| ID11 | 6 | 1 |
| ID12 | 8 | 1 |
| ID13 | 10 | 0 |
| ID13 | 12 | 1 |
| ID14 | 15 | 0 |
| ID15 | 14 | 1 |
| ID16 | 8 | 1 |
| ID17 | 9 | 1 |
we obtain This table :
| Identifiant | Value | |
|---|---|---|
| ID1 | 16 | max(16,8) |
| ID6 | 10 | max(6,10,9,8) |
| ID12 | 8 | max(6,8) |
| ID13 | 12 | max(12) |
| ID15 | 14 | max(14,8,9) |