View source: R/plt-visualize-walks.R
| visualize_walks | R Documentation |
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.
visualize_walks(.data, .alpha = 0.7, .interactive = FALSE, .pluck = FALSE)
.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 |
.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 |
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.
A patchwork composed of 1 or more patches
Antti Lennart Rask
Other Visualization Functions:
animate_double_pendulum(),
plot_double_pendulum()
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.