A function to help build random walks by mutating a data frame.
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
.
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:
confidence_interval()
,
convert_snake_to_title_case()
,
generate_caption()
,
get_attributes()
,
rand_walk_column_names()
,
running_quantile()
,
std_cum_max_augment()
,
std_cum_mean_augment()
,
std_cum_min_augment()
,
std_cum_prod_augment()
,
std_cum_sum_augment()
,
subset_walks()
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)
#> # A tibble: 750 × 8
#> walk_number x y cum_sum cum_prod cum_min cum_max cum_mean
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 -2.09 97.9 -109. 97.9 97.9 97.9
#> 2 1 2 -0.168 97.7 -90.3 97.9 99.8 98.9
#> 3 1 3 -0.890 96.9 -9.90 97.9 99.8 99.0
#> 4 1 4 0.272 97.1 -12.6 97.9 100. 99.3
#> 5 1 5 0.874 98.0 -23.6 97.9 101. 99.6
#> 6 1 6 -0.775 97.2 -5.32 97.9 101. 99.5
#> 7 1 7 0.497 97.7 -7.96 97.9 101. 99.7
#> 8 1 8 -0.887 96.8 -0.899 97.9 101. 99.6
#> 9 1 9 -0.0622 96.8 -0.844 97.9 101. 99.6
#> 10 1 10 -1.31 95.5 0.259 97.9 101. 99.5
#> # ℹ 740 more rows