R/echoice2.R
vd_long_tidy.Rd
Generate tidy choice data with dummies from long-format choice data
vd_long_tidy(longdata)
tibble
tibble
data(icecream)
vd_long_tidy(icecream)
#> # A tibble: 39,600 × 23
#> id task alt x p int Brand:B…¹ Brand…² Brand…³ Brand…⁴ Brand…⁵
#> * <int> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 1 8 0.998 1 0 0 0 0 0
#> 2 1 1 2 0 0.748 1 0 0 0 0 0
#> 3 1 1 3 0 1.25 1 0 0 0 0 0
#> 4 1 1 4 0 0.748 1 0 0 0 0 0
#> 5 1 1 5 0 2.49 1 0 0 0 0 1
#> 6 1 1 6 0 1.25 1 0 0 0 0 1
#> 7 1 1 7 0 1.12 1 0 1 0 0 0
#> 8 1 1 8 0 1.99 1 0 1 0 0 0
#> 9 1 1 9 0 0.622 1 0 0 1 0 0
#> 10 1 1 10 0 3.49 1 0 0 1 0 0
#> # … with 39,590 more rows, 12 more variables: `Brand:Store` <dbl>,
#> # `Flavor:ChocChip` <dbl>, `Flavor:ChocDough` <dbl>,
#> # `Flavor:CookieCream` <dbl>, `Flavor:Neapolitan` <dbl>, `Flavor:Oreo` <dbl>,
#> # `Flavor:RockyRoad` <dbl>, `Flavor:Vanilla` <dbl>,
#> # `Flavor:VanillaBean` <dbl>, `Flavor:VanillaFudge` <dbl>, `Size:8` <dbl>,
#> # `Size:16` <dbl>, and abbreviated variable names ¹`Brand:BlueBell`,
#> # ²`Brand:BlueBunny`, ³`Brand:Breyers`, ⁴`Brand:Dryers`, ⁵`Brand:HaagenDa`