pct_change {metools}R Documentation

Percentual change

Description

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)

nafill

set value to fill NA's before first t value

Value

Return a dataframe.

Examples

v=data.frame(test=c(1,2,3,4,5,6,7,8,9,10,11,12,13))
pct_change(v)


[Package metools version 1.0.0 Index]