pct_change calculate the percentual change in t periods of a serie.
We can use this function to calculate the acumulated variation of an index,
for example to calculate the accumulated variation in 12 months just
set t parameter to 12
Usage
pct_change(data, colnum, t = nrow(data[colnum]) - 1, nafill = NA)
Arguments
data
a dataframe
colnum
number of column
t
number of periods to accumulate (default= number of rows)