title: Money adding program in R
body: <p>I want to create a program in R that takes integer user input and then adds it to the previous user input. ex. user input(say one day): 10, then (maybe the next day) user input: 15  --> output 25.Ideally this would accept nearly an infinite amount of input. here is what I have so far:</p>
  
  <pre><code>amount_spent &lt;- function(){
      i &lt;-1
      while(i&lt;10){
          n &lt;- readline(prompt="How much did you spend?: ")
          i&lt;-i+1
      }
  print(c(as.integer(n)))
  }
  amount_spent()
  </code></pre>
  
  <p>Problems I have with this code are that it only saves the last input value, and it is difficult to control when User is allowed to input. Is there any way to save user input to a data that can be manipulated through readline()?</p>