[1] '1.8.0'
[1] '1.8.0'
# A tibble: 2,412 × 10
id feat.yoplait feat.dannon feat.hiland feat.weight price.yoplait
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 0 0 0 0 10.8
2 1 0 0 0 0 10.8
3 1 0 0 0 0 10.8
4 1 0 0 0 0 10.8
5 1 0 0 0 0 12.5
6 1 0 0 0 0 10.8
7 1 0 0 0 0 10.3
8 1 0 0 0 0 10.8
9 2 0 0 0 0 10.8
10 2 0 0 0 0 10.8
# ℹ 2,402 more rows
# ℹ 4 more variables: price.dannon <dbl>, price.hiland <dbl>,
# price.weight <dbl>, choice <fct>
choice
yoplait dannon hiland weight
0.33914 0.40216 0.02944 0.22927
mean_price.yoplait mean_price.dannon
1 10.68213 8.163474
feat.yoplait feat.dannon feat.hiland feat.weight price.yoplait price.dannon
1 0.05597015 0.03772803 0.03689884 0.03772803 10.68213 8.163474
price.hiland price.weight
1 5.362935 7.949088
#Pivoter le dataframe
Le dataframe est dans un format peu commode qui s’appelle format wide. Il y a beaucoup de colonnes (1+4+4+1). Il est plus commode de créer un format long avec des colonnes id, feat, price, choice, mais on sera obligé d’ajouter une autre colonne.