I'd like to loop through the following data frame in order of the sum of the first 2 column values for each row, and then assign the third column value a number as a result of that.
Initial Table:
Col 1 | Col 2 | Col 3 |
---|---|---|
20 | 0 | |
5 | 0 | |
20 | 0 | |
0 | 10 | |
20 | 0 | |
10 | 0 | |
20 | 40 | |
15 | 0 |
The sums of columns 1 and 2 give:
20+0=20
5+0=5
20+0=20
0+10=10
20+0=20
10+0=10
20+40=60
15+0=15
Col 1 | Col 2 | Col 3 |
---|---|---|
20 | 0 | 10 |
5 | 0 | 20 |
20 | 0 | 10 |
0 | 10 | 20 |
20 | 0 | 10 |
10 | 0 | 20 |
20 | 40 | 5 |
15 | 0 | 20 |
The 3 lowest sums get Col 3 value 20, the next 4 lowest get value 10, and the highest value gets 5.