set_levels | R Documentation |
Set one or more simulation levels, which are things that vary between simulation replicates.
set_levels(sim, ..., .add = FALSE, .keep = NA)
sim |
A simulation object of class |
... |
One or more key-value pairs representing simulation levels. Each value can either be a vector (for simple levels) or a list of lists (for more complex levels). See examples. |
.add |
Only relevant if |
.keep |
An integer vector specifying which level combinations to keep; see examples. |
The original simulation object with the old set of levels replaced with the new set
# Basic usage is as follows: sim <- new_sim() sim %<>% set_levels( "n" = c(10, 100, 1000), "theta" = c(2, 3) ) sim$levels # More complex levels can be set using lists: sim %<>% set_levels( "n" = c(10, 100, 1000), "theta" = c(2, 3), "method" = list( "spline1" = list(knots=c(2,4), slopes=c(0.1,0.4)), "spline2" = list(knots=c(1,5), slopes=c(0.2,0.3)) ) ) sim$levels # By default, set_levels will overwrite old levels if it is called twice: sim %<>% set_levels(alpha=c(1,2), beta=c(5,6)) sim %<>% set_levels(alpha=c(3,4), gamma=c(7,8)) sim$levels # To merge the old levels with the new levels instead, specify .add=TRUE: sim %<>% set_levels(alpha=c(1,2), beta=c(5,6)) sim %<>% set_levels(alpha=c(3,4), gamma=c(7,8), .add=TRUE) sim$levels # If you don't want to run simulations for all level combinations, use the # .keep option. First, set the levels normally. Second, view the # sim$levels_grid dataframe to examine the level combinations and the # associated level_id values. Third, call set_levels again with the .keep # option to specify which levels to keep (via a vector of level_id values). sim %<>% set_levels(alpha=c(1,2,3), beta=c(5,6)) sim$levels_grid sim %<>% set_levels(.keep=c(1,2,6)) sim$levels_grid
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.