Add a step to an existing design

add_step(..., before = NULL, after = NULL)

Arguments

...

bare (unquoted) names of step(s) to add to a design

before

bare (unquoted) name of the step before which to add steps

after

bare (unquoted) name of the step after which to add steps

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.61 0.09 0.07 2.76 1.05 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.61 0.09 0.07 2.76 1.05 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.76 2.30 2.30 7.40 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 #>
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.18 0.09 0.10 2.16 1.06 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.18 0.09 0.10 2.16 1.06 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.86 2.13 2.09 8.18 2.25 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 #> -2.81 -0.10 -0.05 2.65 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.81 -0.10 -0.05 2.65 0.97 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -3.20 1.29 1.62 7.77 2.25 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.42 0.93 7.88 1.50 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.29 0.22 0.10 2.69 1.01 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.29 0.22 0.10 2.69 1.01 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -4.82 2.06 2.00 6.30 2.00 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 1.03 7.25 1.37 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.76 -0.17 -0.15 2.75 1.06 0 100 #> #> Step 2 (potential outcomes): my_potential_outcomes ----------------------------- #> #> Added variable: Y_Z_0 #> min median mean max sd N_missing N_unique #> -2.76 -0.17 -0.15 2.75 1.06 0 100 #> #> Added variable: Y_Z_1 #> min median mean max sd N_missing N_unique #> -2.75 1.46 1.44 7.77 2.32 0 100 #>