We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a helper function to plot out the geometric/brownian motion augment functions.
Function:
ts_brownian_motion_plot <- function(.data, .date_col, .value_col, .interactive = FALSE){ # Tidyeval --- plotly_plot <- as.logical(.interactive) date_var_expr <- rlang::enquo(.date_col) value_var_expr <- rlang::enquo(.value_col) # Attributes atb <- attributes(.data) # Checks --- if (!is.data.frame(.data)){ rlang::abort( message = "'.data' must be either a data.frame/tibble.", use_cli_format = TRUE ) } if (!is.logical(.interactive)){ rlang::abort( message = "'.interactive' must be a logical of TRUE/FALSE.", use_cli_format = TRUE ) } if (!".motion_type" %in% names(atb)){ rlang::abort( message = "The '.data' must come from a ts_brownian or ts_geometric function." ) } # Data Manipulation --- df <- dplyr::as_tibble(.data) # Graph --- g <- df %>% ggplot2::ggplot(ggplot2::aes(x = {{ date_var_expr }}, y = {{ value_var_expr }}, group = sim_number, color = sim_number)) + ggplot2::geom_line() + ggplot2::theme_minimal() + ggplot2::labs( title = atb$.motion_type, subtitle = paste0("Simulations: ", atb$.num_sims, " - Initial Value: ", round(atb$.initial_value, 2), " - Delta Time: ", round(atb$.delta_time, 2)) ) + ggplot2::theme(legend.position = if(atb$.num_sims > 9) {"none"}) # Return --- if (plotly_plot){ g <- plotly::ggplotly(g) } return(g) }
Example:
library(healthyR.ts) library(tidyverse) df <- ts_to_tbl(AirPassengers) %>% select(-index) augmented_data <- df %>% ts_brownian_motion_augment( .date_col = date_col, .value_col = value, .time = 144 ) augmented_data %>% ts_brownian_motion_plot(.date_col = date_col, .value_col = value)
The text was updated successfully, but these errors were encountered:
5aac3d6
spsanderson
No branches or pull requests
Create a helper function to plot out the geometric/brownian motion augment functions.
Function:
Example:
The text was updated successfully, but these errors were encountered: