I have lots of data frame like the one below. I need to find the Total in last sample just before weight value is zero. here for example in the sample of 7 I need to find the weight that is 6.
Sample Weight Total
1 2 0
2 3 0
3 7 0
4 5 4
5 4 3
6 3 8
7 6 12
8 0 11
9 0 8
10 0 9
Here is what i have tried:
New.DF <- DF$Total [ Weight > 0, Sample=max]