I explain with an example, I insert a number (for example, my input is 2010000) and I need the ccompare sum of the values in the third row with my input (my condition : the summation of the elements in the third row <= my input), Until my condition is True, I need to get the values in the first and the second rows. for example in the case of 2010000, I need to get
1 2 3 4
-1 -1 -1 -1
P.S : I should not read the last positive value of the third row.
I could do it with for loops
but as you know loops are not fast for R.
Thanks
My Data:
1 2 3 4 10 37 NA
-1 -1 -1 -1 -1 -1 -6
549493 217514 732961 506807 113712 139339 2259826