Expands the vector of choice variables to a tibble with dummy columns for whether an alternative was chosen. The function uses the sorted unique values of the choice variable to infer the total number of alternatives available (irrespective of whether any of them were chosen)

expand_choices(db, str_id, str_ct, str_choice)

Arguments

db

A data.frame or tibble

str_id

A character string giving the name of the individual id variable

str_ct

A character string giving the name of the choice task variable

str_choice

A character string giving the name of the choice variable

Value

A tibble with the expanded choice variable