rand_walk_helper: Random Walk Helper

View source: R/helpers.R

rand_walk_helperR Documentation

Random Walk Helper

Description

A function to help build random walks by mutating a data frame.

Usage

rand_walk_helper(.data, .value)

Arguments

.data

The data frame to mutate.

.value

The .initial_value to use. This is passed from the random walk function being called by the end user.

Details

A function to help build random walks by mutating a data frame. This mutation adds the following columns to the data frame: cum_sum, cum_prod, cum_min, cum_max, and cum_mean. The function is used internally by certain functions that generate random walks.

Value

A modified data frame/tibble with the following columns added:

  • cum_sum: Cumulative sum of y.

  • cum_prod: Cumulative product of y.

  • cum_min: Cumulative minimum of y.

  • cum_max: Cumulative maximum of y.

  • cum_mean: Cumulative mean of y.

Author(s)

Steven P. Sanderson II, MPH

See Also

Other Utility Functions: convert_snake_to_title_case(), generate_caption(), get_attributes(), running_quantile(), std_cum_max_augment(), std_cum_mean_augment(), std_cum_min_augment(), std_cum_prod_augment(), std_cum_sum_augment()

Examples

df <- data.frame(
  walk_number = factor(rep(1L:25L, each = 30L)),
  x = rep(1L:30L, 25L),
  y = rnorm(750L, 0L, 1L)
  )

rand_walk_helper(df, 100)


RandomWalker documentation built on Oct. 23, 2024, 5:07 p.m.