Learn R Programming

healthyR.ts (version 0.3.1)

ts_acceleration_augment: Augment Function Acceleration

Description

Takes a numeric vector and will return the acceleration of that vector.

Usage

ts_acceleration_augment(.data, .value, .names = "auto")

Value

A augmented tibble

Arguments

.data

The data being passed that will be augmented by the function.

.value

This is passed rlang::enquo() to capture the vectors you want to augment.

.names

The default is "auto"

Author

Steven P. Sanderson II, MPH

Details

Takes a numeric vector and will return the acceleration of that vector. The acceleration of a time series is computed by taking the second difference, so $$(x_t - x_t1) - (x_t - x_t1)_t1$$

This function is intended to be used on its own in order to add columns to a tibble.

See Also

Other Augment Function: ts_growth_rate_augment(), ts_velocity_augment()

Examples

Run this code
suppressPackageStartupMessages(library(dplyr))

len_out    = 10
by_unit    = "month"
start_date = as.Date("2021-01-01")

data_tbl <- tibble(
  date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
  a    = rnorm(len_out),
  b    = runif(len_out)
)

ts_acceleration_augment(data_tbl, b)

Run the code above in your browser using DataLab