plot.summary.mc | R Documentation |
Plot line plots of the path of the summarized output
over all simulation repetitions
of a Monte Carlo simulation run by
future_mc()
and summarized by summary.mc()
## S3 method for class 'summary.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: TRUE |
... |
additional arguments passed to callies. |
Only one of the arguments join
, which_setup
, and paramter_comb
can be specified at a time.
A plot is only created for (output - parameter combination)-pairs
for which in summary.mc()
a function is provided in sum_funs
which returns a single numeric value and if the output
is included in which_path
.
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(summary(test_mc))
returned_plot1$mean +
ggplot2::theme_minimal()
returned_plot2 <- plot(summary(test_mc),
which_setup = test_mc$nice_names[1:2], plot = FALSE)
returned_plot2$mean
returned_plot3 <- plot(summary(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.