Skip to contents

Turns a fully organized Crunch dataset back into a srv_tbl shaped like the project's srv_main — the final survey object, ready for direct synthesis with no further srv_main -> srv_crunch -> crunch_ds transformations.

Usage

crunch_srv_final(crunch_ds, verbose = TRUE)

Arguments

crunch_ds

A Crunch Dataset.

verbose

Logical. Print a summary when TRUE (default).

Value

A srv_tbl (see g6tr.survey::as_srv_tbl()).

Details

The typical pipeline is srv_main (analysis) -> srv_crunch (subset + transforms) -> Crunch (manual reshaping, client-facing names, folders, added variables such as segments and utilities). crunch_srv_final() reverses that last hop: it pulls the Crunch data as a flat tibble and re-attaches the g6tr.survey metadata schema so every column is decorated the way g6tr.survey::step_set_sr() and friends would decorate it.

What it reconstructs:

  • Data via crunch_read_dataset() — a .sav export (hidden variables included), so Crunch arrays are flattened back into their subvariable ("option") columns, matching srv_main's layout.

  • Types mapped from Crunch: categorical -> sr, multiple_response -> mr, categorical_array -> loop_sr, numeric -> fn, text -> ft, datetime -> time. response_id becomes id and the dataset weight (if any) becomes weight.

  • Names / descriptions: each column carries the client-facing Crunch variable name as alias_name and the Crunch description as description. For gathered variables the subvariable name is stored as the option.

  • Folders: the Crunch folder path becomes each column's folder (round-trips with crunch_guess_folders()).

Columns with no matching Crunch metadata are left untyped (a warning lists them); type or re-assign them afterwards with the step_set_*() family (e.g. step_set_folder()).

Examples

if (FALSE) { # \dontrun{
crunch_ds <- crunch_connect()
srv_final <- crunch_srv_final(crunch_ds)
g6tr.survey::get_aliases(srv_final)
} # }