rand_walk_helper {RandomWalker} | R 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 ofy
. -
cum_prod
: Cumulative product ofy
. -
cum_min
: Cumulative minimum ofy
. -
cum_max
: Cumulative maximum ofy
. -
cum_mean
: Cumulative mean ofy
.
Author(s)
Steven P. Sanderson II, MPH
See Also
Other Utility Functions:
convert_snake_to_title_case()
,
generate_caption()
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)