Learn R Programming

RandomWalker (version 0.1.0)

rand_walk_helper: Random Walk Helper

Description

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

Usage

rand_walk_helper(.data, .value)

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.

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.

Author

Steven P. Sanderson II, MPH

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.

See Also

Other Utility Functions: convert_snake_to_title_case(), generate_caption()

Examples

Run this code
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)

Run the code above in your browser using DataLab