Replace a step in an existing design

replace_step(..., replace)

## Arguments

... bare (unquoted) names of step(s) to replace in a design bare (unquoted) name of step to be replaced

## Details

see modify_design for details.

## Examples


my_population <- declare_population(N = 100, noise = rnorm(N))

my_potential_outcomes <-
declare_potential_outcomes(Y_Z_0 = noise,
Y_Z_1 = noise + rnorm(N, mean = 2, sd = 2))

my_assignment <- declare_assignment(m = 50)
my_assignment_2 <- declare_assignment(m = 25)

design <- declare_design(my_population,
my_potential_outcomes,
my_assignment)

design#>
#> Design Summary
#>
#> Step 1 (population): my_population ---------------------------------------------
#>
#> N = 100
#>
#>  N_missing N_unique
#>          0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -2.27   0.20 0.17 2.51 0.94         0      100
#>
#> Step 2 (potential outcomes): my_potential_outcomes -----------------------------
#>
#>    min median mean  max   sd N_missing N_unique
#>  -2.27   0.20 0.17 2.51 0.94         0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -5.06   2.17 2.03 6.22 2.31         0      100
#>
#> Step 3 (assignment): my_assignment ---------------------------------------------
#>
#>                0    1
#>   Frequency   50   50
#>  Proportion 0.50 0.50
#>
#>              0.5
#>   Frequency  100
#>  Proportion 1.00
#>
modify_design(design, replace_step(my_assignment_2, replace = my_assignment))#>
#> Design Summary
#>
#> Step 1 (population): my_population ---------------------------------------------
#>
#> N = 100
#>
#>  N_missing N_unique
#>          0      100
#>
#>    min median  mean  max   sd N_missing N_unique
#>  -2.42   0.14 -0.03 1.97 0.97         0      100
#>
#> Step 2 (potential outcomes): my_potential_outcomes -----------------------------
#>
#>    min median  mean  max   sd N_missing N_unique
#>  -2.42   0.14 -0.03 1.97 0.97         0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -3.57   2.41 2.10 7.32 2.18         0      100
#>
#> Step 3 (assignment): my_assignment_2 -------------------------------------------
#>
#>                0    1
#>   Frequency   75   25
#>  Proportion 0.75 0.25
#>
#>             0.25 0.75
#>   Frequency   25   75
#>  Proportion 0.25 0.75
#>
modify_design(design, add_step(dplyr::mutate(income = noise^2), after = my_assignment))#>
#> Design Summary
#>
#> Step 1 (population): my_population ---------------------------------------------
#>
#> N = 100
#>
#>  N_missing N_unique
#>          0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -1.46   0.08 0.08 2.42 0.84         0      100
#>
#> Step 2 (potential outcomes): my_potential_outcomes -----------------------------
#>
#>    min median mean  max   sd N_missing N_unique
#>  -1.46   0.08 0.08 2.42 0.84         0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -3.73   2.10 2.07 8.31 2.26         0      100
#>
#> Step 3 (assignment): my_assignment ---------------------------------------------
#>
#>                0    1
#>   Frequency   50   50
#>  Proportion 0.50 0.50
#>
#>              0.5
#>   Frequency  100
#>  Proportion 1.00
#>
#> Step 4 (declare step): dplyr::mutate(income = noise^2) -------------------------
#>
#>   min median mean  max   sd N_missing N_unique
#>  0.00   0.38 0.71 5.87 0.94         0      100
#>  modify_design(design, add_step(dplyr::mutate(income = noise^2), before = my_assignment))#>
#> Design Summary
#>
#> Step 1 (population): my_population ---------------------------------------------
#>
#> N = 100
#>
#>  N_missing N_unique
#>          0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -2.37   0.49 0.19 1.73 0.81         0      100
#>
#> Step 2 (potential outcomes): my_potential_outcomes -----------------------------
#>
#>    min median mean  max   sd N_missing N_unique
#>  -2.37   0.49 0.19 1.73 0.81         0      100
#>
#>    min median mean  max   sd N_missing N_unique
#>  -3.76   1.97 1.80 6.46 2.10         0      100
#>
#> Step 3 (declare step): dplyr::mutate(income = noise^2) -------------------------
#>
#>   min median mean  max   sd N_missing N_unique
#>  0.00   0.49 0.69 5.64 0.81         0      100
#>
#> Step 4 (assignment): my_assignment ---------------------------------------------
#>
#>                0    1
#>   Frequency   50   50
#>  Proportion 0.50 0.50
#>
#>              0.5
#>   Frequency  100
#>  Proportion 1.00
#>
modify_design(design, remove_step(my_assignment))#>
#> Design Summary
#>
#> Step 1 (population): my_population ---------------------------------------------
#>
#> N = 100
#>
#>  N_missing N_unique
#>          0      100
#>
#>