I have a data.frame
with 13 columns and 78 rows. I need to do for each column ((x1/x2)^12)-1
, being x1
the value contained in the first row of the first column, x2
the value contained in the second row of the first column, and I need to apply this function for all rows. To automate the process I thought of using the rollapply
function, the problem is in the elaboration of the function. How can I, in r, use the successive values of a column as arguments to a function?