Merging two files
choc_alts
and choc_choice
are still loaded. In the last exercise, you manually identified the rows in each file corresponding to the same choice. In this exercise, you'll merge the two files together to get the chocolate data back to long format.
Diese Übung ist Teil des Kurses
Choice Modeling for Marketing in R
Anleitung zur Übung
- Merge the
choc_choice
andchoc_alts
files together matching on theSubject
andTrial
. Assign the result tochoc_merge
. - Convert the
Selection
variable inchoc_merge
from an integer indicating the alternative that was chosen to a logical (TRUE/FALSE
) as you have done in previous exercises. - Use
head()
to inspectchoc_merge
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Merge choc_choice and choc_alts
choc_merge <- merge(___, ___, by=c("___", "___"))
# Convert Selection to a logical variable
choc_merge$Selection <- ___ == ___
# Inspect chocolate_merge using head
head(choc_merge)