Skip to contents

A frame is a data frame or a non-empty ordered list of data frames. A data frame and a one-element list containing it have the same meaning. execute() also accepts one data frame per stage as separate arguments in ....

Details

One hierarchy or separate registers

A single hierarchy contains the rows needed for the requested stages, including parent identifiers. Variables describing a selected cluster, such as its MOS and stratum, must be constant within that cluster. Separate registers describe one sampling level each and map positionally to the requested stages. List names label registers in messages. They do not reorder stages or define joins. Child registers carry the parent keys needed to identify eligible descendants.

Continuing fieldwork

Use execute(partial_sample, next_register) to resume the same design after listing. The earlier selection and weights are retained, and omitting stages executes every remaining stage. If one supplied frame could cover either the next stage or several remaining stages, the two draw different samples, so execute() refuses to guess and asks for stages (samplyr_error_ambiguous_continuation). validate_frame() applies the same rule.

A listing derived from the partial sample, for example with dplyr::reframe() or tidyr::uncount(), may carry its generated columns (.weight, .fpc_1, ...). A continuation strips them before sampling, except .draw_k. A unit drawn more than once by a with-replacement method has one row per draw in the sample, so a listing derived from those rows lists the unit once per draw. Its .draw_k columns tell each draw which rows are its own. A listing without them lists each unit once, and every draw of the unit samples those rows. Build such a listing from the unique selected units, and keep .draw_k whenever a listing expands the sample's rows. A listing that keeps .draw_k but leaves out a draw of a unit it lists, or names a draw that was not made, is refused (samplyr_error_frame_draws). Passing the original design as .data instead starts a new execution at stage 1 and treats a tbl_sample frame as a previous phase. When that frame is a strict partial result of the same design, execute() warns but proceeds, since a new phase is a valid operation. A plain listing that still carries sampling attributes or generated columns is refused as the frame of a fresh design execution. To use such rows as an unrelated frame, remove both.

Use execute(new_design, previous_sample) to select a new phase from an earlier sample. This records an additional probability-sampling operation. It is distinct from continuing the unfinished stages of a design.

Frame checks apply before selection: column names must be unambiguous, design variables must be present, and keys and cluster-level variables must satisfy the design's identity rules. A frame fingerprint in a saved design records the supplied data. It does not certify executability.

Other data frame classes

A frame of a class that extends data.frame, other than a tibble, is read by its columns. Every column is kept with its own class, and the frame class's own methods (for example a subsetting rule that always keeps a column) are not used, so the sample is the one the same columns in a plain data frame give. The sample is a tibble whatever the frame's class.

The grouping of a grouped or rowwise frame is ignored, and the result is not grouped. Grouping does not stratify a design: strata are declared with stratify_by(). The first time this happens in a session a message says so.