index: Indexing a time series

Description Usage Arguments Value Examples

View source: R/index.R

Description

Scales a time series in such a way that it gets the value 100 at a given point in time

Usage

1
index(val, time_var, at_time = min(time_var[!is.na(val)], na.rm = TRUE))

Arguments

val

a numeric variable to scale

time_var

time variable or other indexing variable

at_time

the time or index value at the base year

Value

A scaled series.

Examples

1
2
3
economics_long %>%
 group_by(variable) %>%
 mutate(val = index(value, date))

karsfri/HMSr documentation built on Feb. 26, 2020, 10:36 a.m.