pct_change: Percentual change

Description Usage Arguments Value Examples

View source: R/pctchange.R

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

1
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

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

metools documentation built on July 2, 2020, 2:28 a.m.

Related to pct_change in metools...