Replace a step in an existing design

replace_step(..., replace)

Arguments

...

bare (unquoted) names of step(s) to replace in a design

replace

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 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> 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 ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.27 0.20 0.17 2.51 0.94 0 100 #> #> Added variable: Y_Z_1 #> 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 --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.00 #>
modify_design(design, replace_step(my_assignment_2, replace = my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> 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 ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.42 0.14 -0.03 1.97 0.97 0 100 #> #> Added variable: Y_Z_1 #> 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 ------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 75 25 0 #> Proportion 0.75 0.25 0.00 #> #> Added variable: Z_cond_prob #> 0.25 0.75 NA #> Frequency 25 75 0 #> Proportion 0.25 0.75 0.00 #>
modify_design(design, add_step(dplyr::mutate(income = noise^2), after = my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> 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 ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -1.46 0.08 0.08 2.42 0.84 0 100 #> #> Added variable: Y_Z_1 #> 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 --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.00 #> #> Step 4 (declare step): dplyr::mutate(income = noise^2) ------------------------- #> #> Added variable: income #> 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 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> 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 ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.37 0.49 0.19 1.73 0.81 0 100 #> #> Added variable: Y_Z_1 #> 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) ------------------------- #> #> Added variable: income #> 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 --------------------------------------------- #> #> Added variable: Z #> 0 1 NA #> Frequency 50 50 0 #> Proportion 0.50 0.50 0.00 #> #> Added variable: Z_cond_prob #> 0.5 NA #> Frequency 100 0 #> Proportion 1.00 0.00 #>
modify_design(design, remove_step(my_assignment))
#> #> Design Summary #> #> Step 1 (population): my_population --------------------------------------------- #> #> N = 100 #> #> Added variable: ID #> N_missing N_unique #> 0 100 #> #> Added variable: noise #> min median mean max sd N_missing N_unique #> -2.55 -0.11 -0.07 2.69 1.00 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.55 -0.11 -0.07 2.69 1.00 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.96 2.09 2.01 8.44 2.26 0 100 #>