Learn R Programming

RandomWalker (version 1.1.0)

visualize_walks: Visualize Walks

Description

visualize_walks() visualizes the output of the random walk functions in the RandomWalker package, resulting in one or more ggplot2 plots put together in a patchwork composed of 1 or more patches.

Usage

visualize_walks(.data, .alpha = 0.7, .interactive = FALSE, .pluck = FALSE)

Value

A patchwork composed of 1 or more patches

Arguments

.data

The input data. Assumed to be created by one of the random walk functions in the RandomWalker package, but can be any data frame or tibble that contains columns walk_number, step_number, and one or more numeric columns like y, x, z, cum_sum_y, cum_prod_y, cum_min_y, cum_max_y, and cum_mean_y, for instance.

.alpha

The alpha value for all the line charts in the visualization. Values range from 0 to 1. Default is 0.7.

.interactive

A boolean value. TRUE if you want the patches to be interactive. FALSE if you don't. Default is FALSE.

.pluck

If you want to visualize only one or more plots, supply a numeric vector of plot indices or a character vector of plotted column names. Exact column names such as y, cum_sum_y, or cum_sum_x are supported. Short cumulative aliases such as cum_sum are supported only when they match exactly one plotted column. Default is FALSE.

Author

Antti Lennart Rask

Details

visualize_walks() generates visualizations of the random walks generated by the random walk functions in the RandomWalker package. These are the functions at the moment of writing:

  • brownian_motion()

  • discrete_walk()

  • geometric_brownian_motion()

  • random_normal_drift_walk()

  • random_normal_walk()

  • rw30()

It is possible there are more when you read this, but you can check the rest of the documentation for the current situation.

The visualization function is meant to be easy to use. No parameters needed, but you can set .alpha if the default value of 0.7 isn't to your liking.

You can also choose whether you want the visualization to be interactive or not by setting .interactive to TRUE. The function uses the ggiraph package for making the patches interactive.

If you want to visualize only one of the attributes, use .pluck with a numeric plot index or the exact column name to plot. Generator functions with cumulative statistics use dimension-suffixed column names such as cum_sum_y, cum_sum_x, and cum_sum_z. Short cumulative aliases such as cum_sum are also accepted when they match exactly one plotted column.

See Also

Other Visualization Functions: animate_double_pendulum(), plot_double_pendulum()

Examples

Run this code
# Generate random walks and visualize the result
set.seed(123)
rw30() |>
 visualize_walks()

# Use the function to create interactive visualizations
set.seed(123)
random_normal_walk(.num_walks = 5, .initial_value = 100) |>
 visualize_walks(.interactive = TRUE)

# Use .pluck to pick just one visualization
set.seed(123)
random_normal_walk(.num_walks = 5, .initial_value = 100) |>
 visualize_walks(.pluck = c(1, 3))

# Use an exact suffixed cumulative column name
set.seed(123)
random_normal_walk(.num_walks = 5, .initial_value = 100) |>
 visualize_walks(.pluck = "cum_sum_y")

Run the code above in your browser using DataLab