i did solve the problem

This isn't R code. That is probably the problem. You don't necessarily need a loop. Many ways of doing it.

Can you give me an example then? I'm truly stucked

Can you provide a reproducible example of your dataset?

I did solve the problem

Isn't it a transition matrix that you would raise to power n to see the values at year n? :thinking: