Build the final survey tibble from a Crunch dataset
Source:R/crunch_srv_final.R
crunch_srv_final.RdTurns 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.
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.savexport (hidden variables included), so Crunch arrays are flattened back into their subvariable ("option") columns, matchingsrv_main's layout.Types mapped from Crunch:
categorical -> sr,multiple_response -> mr,categorical_array -> loop_sr,numeric -> fn,text -> ft,datetime -> time.response_idbecomesidand the dataset weight (if any) becomesweight.Names / descriptions: each column carries the client-facing Crunch variable name as
alias_nameand the Crunch description asdescription. For gathered variables the subvariable name is stored as theoption.Folders: the Crunch folder path becomes each column's
folder(round-trips withcrunch_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)
} # }