-2

How would I create a loop in R for the following: I deposit $10,000 a year that is compounded at an annual rate of 6% I want the loop to break when I reach $1,000,000.

user3576898
  • 65
  • 1
  • 1
  • 5
  • 1
    Please supply [a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of your data and code. – Thomas Apr 26 '14 at 20:24

1 Answers1

0

Depending on when the deposit is made and when the interest is accrued, you might need to change the formula slightly. You didn't specify what the results should look like, so this code just prints each year's balance to the console.

amt = 0
while (amt <= 1000000) {
    amt = amt * 1.06 + 10000
    print(amt)
}
user2926101
  • 314
  • 1
  • 3
  • 13