Iterates over all pending (lazy) steps attached to a Survey or RotativePanelSurvey and executes them sequentially, mutating the underlying data.table. Each step is validated before execution (checks that required variables exist).
Details
Steps are executed in the order they were added. Each step's expressions can reference variables created by previous steps.
For RotativePanelSurvey objects, steps are applied to both the implantation and all follow-up surveys.
See also
Other steps:
get_steps(),
step_compute(),
step_filter(),
step_join(),
step_recode(),
step_remove(),
step_rename(),
step_validate(),
view_graph()
Examples
dt <- data.table::data.table(id = 1:5, age = c(15, 30, 45, 50, 70), w = 1)
svy <- Survey$new(
data = dt, edition = "2023", type = "test",
psu = NULL, engine = "data.table", weight = add_weight(annual = "w")
)
svy <- step_compute(svy, age2 = age * 2)
svy <- bake_steps(svy)
get_data(svy)
#> id age w age2
#> <int> <num> <num> <num>
#> 1: 1 15 1 30
#> 2: 2 30 1 60
#> 3: 3 45 1 90
#> 4: 4 50 1 100
#> 5: 5 70 1 140