acum_i: Transform variables in index form into variables in...

Description Usage Arguments Value Author(s) Examples

View source: R/acum_i.R

Description

Given a numeric vector in index form the function creates a numeric vector with in accumulated percentage in n periods relative to the previous n periods.

Usage

1

Arguments

data

A numeric vector

n

Number of periods to accumulate

Value

A numeric vector in accumulated percentage.

Author(s)

J. Renato Leripio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 

library(tidyverse)
library(tstools)

data <- tibble(Date = seq.Date(from = as.Date("2012-01-01"),
                               to = as.Date("2018-06-01"),
                               by = "month"),

               Index = rep(100, 78) + cumsum(rnorm(mean = 0, sd = 1, n = 78)))



data_acum <- dplyr::mutate(data, Index_acum12 = acum_i(Index, 12))
              
## End(Not run)

leripio/tstools documentation built on Aug. 1, 2019, 12:52 p.m.