title: Adding Some Values in table using loop - R
body: <p>I have a table and I can read the file. I want to add the values in the table under constraints that the addition of values should not be more than given value. What loop should I use?? 
  Example, how can I read and add consecutive values.<br>
  Rank  Number<br>
  1.    10<br>
  2.    8<br>
  3.    9<br>
  4.    6<br>
  5.    5<br>
  6.    7<br>
  7.    4<br>
  8.    1<br>
  9.    3<br>
  10.   2</p>
  
  <p>I have to add the values such that rank should be less but addition should be less than 10. The answer will be Numbers 9 and 1. 
  <a href="https://i.stack.imgur.com/zZq9C.png" rel="nofollow noreferrer">enter image description here</a></p>