Skip to contents

Attach the flat, fixed-schema metadata tibble to a survey column. Every typed column carries the same columns (see Details), NA where a field does not apply — so metadata is trivial to scan, filter and extract.

Usage

set_var_metadata(
  x,
  type,
  alias = NULL,
  alias_name = NULL,
  description = NULL,
  alias_cols = NULL,
  elements = NULL,
  folder = NULL,
  folder_cols = NULL
)

Arguments

x

A vector (survey column).

type

Variable type (e.g. "sr", "mr", "loop_sr", "ft", "fn", "derived", "weight", "ignore", "id", "secondary_id", "time", "response_status").

alias

Alias — the group key. Defaults to the column name upstream.

alias_name

Human-friendly display name for the alias/group.

description

Question / variable description (template-parsed or supplied).

alias_cols

The tidyselect expression used to select the group's columns.

elements

Named list of template placeholders (e.g. list(option = "White")), each stored as its own flat field. Names may not collide with the structural fields.

folder

Folder / path (set later by step_set_folder()). May be nested, e.g. "Module 1/Section A".

folder_cols

The tidyselect expression used to assign the folder.

Details

Structural fields (always present): type, alias, alias_name, description, question, alias_cols, folder, folder_cols. question mirrors description (still read by g6tr.crunch); prefer description. Any template placeholders (option, loop, left, right, ...) are stored as extra flat fields via elements.