Skip to contents

Produce a first-pass draft of the typing calls for a survey — one row per alias group with the guessed type and a ready-to-paste step_set_*() line. It is the seed for R/step_set_types.R: take guess, then correct loop-vs-mr calls, aliases and templates by hand against the survey document. The guess uses the Forsta datamap type where present; where it is missing (or the data did not come from Forsta) the type is inferred from the column data itself (sr/mr/ft/fn). When neither is conclusive the row emits a step_set____() placeholder that errors when sourced, so nothing is silently mis-typed. step_set_ignore() is never emitted (mark survey plumbing by hand).

Usage

forsta_guess_types(x, remove_typed = TRUE)

Arguments

x

Survey data (srv_tbl).

remove_typed

Logical. If TRUE (default), only still-untyped variables are considered, so re-running narrows the list each pass.

Value

A tibble, one row per alias group: guess (the emitted step_set_*() code), alias, type (guessed), n_var, and variables (the group's columns).

Examples

if (FALSE) { # \dontrun{
x <- forsta_get_data("selfserve/57a/250405") |> step_prepare_forsta()
forsta_guess_types(x) |> pull(guess)
} # }