For loop for YoY computation in a data frame

I have a data frame of monthly data and I would like to compute the YoY change rate of every month (the data starts in 2010 and there are 12 obs per year, with 40 variables).
My problem is to call the row i + 12 in the for loop.
The general formula I want to apply is:
X t <- Row t
X t+12 / X t * 100 - 100

Can someone help, please?
Thanks in advance

Hello @pgcgp06. I’d suggest looking into this resource for use of window functions, or this post for some ideas for both tidyverse and base R approaches.