I am trying to write a function that calculates my salary increase every year if I assume the same percent increase each year.
I have tried some of the following code already, but it just outputs the first iteration of the calculation several times.
Here is my function:
salary_func=function(a,b){
for(i in 1:a){
c=b+(b*0.035)
print(c)
}
}
The first argument should be the number of years I'd like to "forecast" out and the second argument should be the starting salary. So, I'd like to see the output that reads:
[1] 103500
[1] 107122.5
and so on until the a-th argument.
But it just reads:
[1] 103500
[1] 103500
What little piece am I missing?