R from For-Loop to apply : this is my second day developing in R, so please bare with me/forgive any naivety. My following code has Vector BaseSal with the Base Salary for 38 different positions, as well as Vector AnnualInc which is the annual amount the Base Salary increases for each of the 38 positions. This code works perfectly:

    for (i in 1:38)
      print(BaseSal[i]+(AnnualInc[i] * 0:10));

The reason for the rang 0:10 is 0 is the first year salary, and the annual increment is added each year for 10 years.

And I was actually surprised at how little I had to do to get there. I have read a bit about apply being better for use in R, and I have it partially working in apply. The results I get deliver me the value of if the first years annual increase was applied to the base salary. Here is the code I'm using to get there :

    l<-matrix(BaseSal,38,11,FALSE); 
    apply(l,2,function(z) z+(AnnualInc));

Can anyone help me figure out how to iterate through each years increment using a matrix and apply, including leaving the first year as just the base salary?