plot.mc | R Documentation |
Plot density plots for numeric results and bar plots for non-numeric results
of a Monte Carlo Simulation run by future_mc()
.
## S3 method for class 'mc'
plot(
x,
join = NULL,
which_setup = NULL,
parameter_comb = NULL,
plot = TRUE,
...
)
x |
An object of class |
join |
A character vector containing the |
which_setup |
A character vector containing the |
parameter_comb |
Alternative to |
plot |
Boolean that specifies whether
the plots should be printed while calling the function or not.
Default: |
... |
ignored |
Only one of the arguments join
, which_setup
, and paramter_comb
can be specified at one time.
A list whose components are named after the outputs of fun
and each component
contains an object of class ggplot
and gg
which can be plotted and modified with the
ggplot2 functions.
test_func <- function(param = 0.1, n = 100, x1 = 1, x2 = 2){
data <- rnorm(n, mean = param) + x1 + x2
stat <- mean(data)
stat_2 <- var(data)
if (x2 == 5){
stop("x2 can't be 5!")
}
return(list(mean = stat, var = stat_2))
}
param_list <- list(param = seq(from = 0, to = 1, by = 0.5),
x1 = 1:2)
set.seed(101)
test_mc <- future_mc(
fun = test_func,
repetitions = 1000,
param_list = param_list,
n = 10,
x2 = 2
)
returned_plot1 <- plot(test_mc)
returned_plot1$mean +
ggplot2::theme_minimal() +
ggplot2::geom_vline(xintercept = 3)
returned_plot2 <- plot(test_mc,
which_setup = test_mc$nice_names[1:2], plot = FALSE)
returned_plot2$mean
returned_plot3 <- plot(test_mc,
join = test_mc$nice_names[1:2], plot = FALSE)
returned_plot3$mean
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.