Skip to contents

Simulate records

Usage

simulate_rcrds(.data, ..., .seed = NULL, .nsim = 1L)

Arguments

.data

An edibble data

...

A name-value pair where the name should correspond to the names used in the simulate_process(). The value should be returned from calling with_params().

.seed

An optional seed value.

.nsim

The number of times to simulate data.

Examples

design() %>%
 set_units(unit = 4) %>%
 set_trts(trt = 2) %>%
 allot_table(trt ~ unit) %>%
 set_rcrds(y = unit) %>%
 simulate_process(y = function() {
            res <- rnorm(n())
            res
 }) %>%
 simulate_rcrds(y = with_params(), .nsim = 3)
#> # An edibble: 12 x 4
#>      unit    trt      y  .sim
#>    <U(4)> <T(2)>             
#>     <chr>  <chr>  <dbl> <int>
#>  1  unit1   trt2  0.616     1
#>  2  unit2   trt1 -1.31      1
#>  3  unit3   trt1  1.02      1
#>  4  unit4   trt2 -0.971     1
#>  5  unit1   trt2 -1.63      2
#>  6  unit2   trt1  2.71      2
#>  7  unit3   trt1 -0.953     2
#>  8  unit4   trt2  1.44      2
#>  9  unit1   trt2 -1.55      3
#> 10  unit2   trt1  0.154     3
#> 11  unit3   trt1  0.505     3
#> 12  unit4   trt2 -0.856     3