Converts a vector of choices into a long format data frame, where each row represents a single choice and contains the choice status for each alternative.
ec_util_choice_to_long(myvec, all_index)
A vector of choices, where each element represents the index of the chosen alternative.
A vector of all the possible alternative indices.
A tibble with columns 'x', 'task', and 'alt', where 'x' is a binary indicator of whether the alternative was chosen or not, 'task' is the task index, and 'alt' is the alternative index.
#There are 3 alternatives in this task.
#Since there are 3 observations in myvec, there are 3 tasks total.
ec_util_choice_to_long(c(1, 2, 1), c(1, 2, 3))
#> # A tibble: 9 × 3
#> x task alt
#> <dbl> <int> <int>
#> 1 1 1 1
#> 2 0 1 2
#> 3 0 1 3
#> 4 0 2 1
#> 5 1 2 2
#> 6 0 2 3
#> 7 1 3 1
#> 8 0 3 2
#> 9 0 3 3