Skip to contents

Returns the stage indices that have been executed for a tbl_sample. For a fully executed single-stage design, this is typically 1L. For partial execution or continuation workflows, this indicates how far the design has progressed.

Usage

get_stages_executed(x)

Arguments

x

A tbl_sample object.

Value

An integer vector of executed stage numbers.

Details

This is mainly useful for:

  • checking whether a multi-stage design was executed completely

  • writing continuation workflows that resume from the next stage

  • inspecting samples created with stages = in execute()

Examples

design <- sampling_design() |>
  add_stage("EAs") |>
    cluster_by(ea_id) |>
    draw(n = 10) |>
  add_stage("Households") |>
    draw(n = 5)

stage1 <- execute(design, bfa_eas, stages = 1, seed = 1)
get_stages_executed(stage1)
#> [1] 1

full_sample <- execute(stage1, bfa_eas, seed = 2)
#> Warning: Stage 2: selected every unit available in the pools it executed.
#>  Requested 50 units, selected all 10 available.
#>  Exhausted pools: "11611", "15528", "45236", "21818", "43475", and 5 more.
#>  This stage contributes no sampling variance. Earlier stages are unaffected:
#>   the design as a whole is a census only if every stage is.
get_stages_executed(full_sample)
#> [1] 1 2