Assignment 8 Solutions

Load the required libraries

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Load the dataset

data <- read.csv("~/Downloads/ExpandedF21DataSurveyWithSectionsAnonymized.csv", header=FALSE)
head(data)
##     V1                 V2               V3                                V4
## 1   ID PopularFoodDislike       DressColor                          Floaters
## 2 1687           Eggplant   Blue and black                 Yes, occasionally
## 3 4766              Steak   Blue and black I'm not sure what things you mean
## 4 9599     Sweet Potatoes   White and gold                 Yes, occasionally
## 5 6909            pickles I don't remember                 Yes, occasionally
## 6 7095              Sushi   Blue and black                                No
##       V5                 V6
## 1 Animal ChocolateOrVanilla
## 2    Pig          Chocolate
## 3  Zebra            Vanilla
## 4  Tiger          Chocolate
## 5  panda          Chocolate
## 6    cat            Vanilla
##                                                               V7
## 1                                                RightLeftHanded
## 2                                                   Right-handed
## 3                                                   Right-handed
## 4                                                   Ambidextrous
## 5 mostly right-handed, but left-handed with very specific things
## 6                                                   Right-handed
##                  V8                    V9              V10               V11
## 1       RotaryPhone ThermostatTemperature NumberFrom1to100         MovieStar
## 2     Not 100% sure                Cooler               52  Jennifer Aniston
## 3     Not 100% sure                Cooler               78         Tom Hanks
## 4 Yes, I believe so                Cooler               28 Denzel Washington
## 5 Yes, I believe so                Warmer               24          Gong Yoo
## 6           A what?                Cooler               50 Robert Downey Jr.
##             V12           V13                    V14
## 1 CanRollTongue CellPhoneType FavoriteNumberFrom1to5
## 2           Yes        iPhone                      1
## 3            No        iPhone                      5
## 4           Yes        iPhone                      5
## 5            No                                    4
## 6           Yes       Android                      2
##                            V15                    V16
## 1                 FavoriteTeam GrossedOutByFoodAnswer
## 2                                   Yes, most of them
## 3                       Soccer                     No
## 4 Seleccion Nacional De Mexico                     No
## 5                                                  No
## 6                                                  No
##                                                                  V17
## 1                                                   ThrowingOutSocks
## 2                                 No, but I'm totally doing that now
## 3 I did the throwing out thing, but didn't talk to everyone about it
## 4                                                                 No
## 5                                                                 No
## 6                                                                 No
##              V18        V19                 V20          V21
## 1 OddEvenSection SectionDay Activity_Basketball Activity_Ski
## 2            Odd    Tuesday                   0            0
## 3            Odd   Thursday                   0            0
## 4            Odd    Tuesday                   0            0
## 5            Odd   Thursday                   0            1
## 6           Even    Tuesday                   0            0
##                    V22                 V23             V24               V25
## 1 Activity_HorseRiding Activity_StickShift Activity_Rubiks Activity_Unicycle
## 2                    0                   0               0                 0
## 3                    0                   1               0                 0
## 4                    0                   0               1                 0
## 5                    0                   0               1                 0
## 6                    0                   0               1                 0
##               V26             V27               V28          V29            V30
## 1 Activity_Stilts Activity_Juggle Activity_IceSkate Tried_Snails Tried_FrogLegs
## 2               0               0                 1            0              0
## 3               0               0                 1            0              0
## 4               0               0                 0            0              0
## 5               0               0                 1            0              0
## 6               0               0                 1            0              0
##           V31            V32          V33                      V34
## 1 Tried_Natto Tried_Aligator Tried_Durian Tried_ThousandYearOldEgg
## 2           0              0            1                        0
## 3           0              0            0                        0
## 4           0              0            0                        0
## 5           0              0            0                        0
## 6           0              1            0                        0
##              V35            V36              V37              V38
## 1 Dislike_Coffee Dislike_Yogurt Dislike_Cilantro Dislike_Tomatoes
## 2              0              0                0                1
## 3              0              0                0                1
## 4              0              0                0                0
## 5              0              0                1                1
## 6              0              0                0                1
##                        V39          V40                       V41
## 1 Dislike_CarbonatedDrinks Dislike_Eggs Dislike_ChocolateIceCream
## 2                        0            0                         0
## 3                        0            0                         0
## 4                        0            0                         0
## 5                        0            0                         0
## 6                        0            1                         0
##               V42           V43               V44             V45
## 1 Follow_Football Follow_Soccer Follow_Basketball Follow_Baseball
## 2               1             0                 0               0
## 3               0             0                 0               0
## 4               1             1                 1               0
## 5               0             1                 0               0
## 6               0             0                 0               0
##              V46
## 1 Follow_Cricket
## 2              0
## 3              0
## 4              0
## 5              0
## 6              0

Let’s lookup the ID for Professor Marian

“Prof. Marian grew up in France, in prehistoric times, before the internet and push-button phones. She was raised on all types of weird French foods, but never developed a taste for mushrooms and think cilantro tastes like soap.”

#She dislikes Mushrooms and Cilantro
prof<-data%>%filter(data$V2=="Mushrooms" & data$V37 == 1)
head(prof)
##     V1        V2                                  V3                V4  V5
## 1 5680 Mushrooms A color combination not listed here Yes, occasionally Cat
##        V6           V7              V8     V9 V10          V11 V12    V13 V14
## 1 Vanilla Right-handed Yes, and I have Warmer  42 Meryl Streep Yes iPhone   4
##   V15 V16                                V17  V18  V19 V20 V21 V22 V23 V24 V25
## 1      No No, but I'm totally doing that now <NA> <NA>   0   1   1   1   1   0
##   V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37 V38 V39 V40 V41 V42 V43 V44
## 1   0   0   0   1   1   1   1   0   0   1   0   1   0   0   0   0   0   0   0
##   V45 V46
## 1   0   0

Let’s look up the ID’s of the TAs

“Aditya grew up in Mumbai, India. His favourite food choices include fast foods, and he drinks a lot of coffee. He somehow still hates kale (maybe because of the weird taste), but absolutely loves chocolates. He is also an expert in driving a stick shift car with ease. He keeps in touch with sports, especially basketball, and can dunk in a hoop quite well. One wonderful aspect is his ability to keep in touch with ancient times, by knowing how to operate a rotary phone.”

##     V1   V2             V3                V4      V5        V6           V7
## 1 8964 Kale Blue and black Yes, occasionally Giraffe Chocolate Right-handed
##                  V8     V9 V10                V11 V12     V13 V14      V15
## 1 Yes, I believe so Cooler  23 Leonardo Di caprio Yes Android   2 Man City
##               V16
## 1 Yes, one or two
##                                                                  V17  V18
## 1 I did the throwing out thing, but didn't talk to everyone about it Even
##       V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
## 1 Tuesday   1   0   0   1   0   1   0   0   0   0   0   0   0   0   0   0   0
##   V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   1   0   0   0   0   0   1   0   0   1

“Vedang was born and brought up in India, where the most popular sports are soccer and cricket, which he follows. Even though he dislikes its smell, he loves the taste of the tropical fruit, Durian. He is fascinated by deep-sea animals such as the Jellyfish and suggests that”The Dress" is gold and white in colour when the topic comes up in a conversation."

Vedang<-data%>%filter(data$V5=="Jellyfish")
Vedang
##     V1      V2             V3                V4        V5      V6           V7
## 1 7486 Burgers White and gold Yes, occasionally Jellyfish Vanilla Right-handed
##                V8     V9 V10               V11 V12    V13 V14 V15 V16 V17 V18
## 1 Yes, and I have Warmer  79 Leonardo DiCaprio Yes iPhone   5      No  No Odd
##        V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
## 1 Thursday   0   0   1   0   1   0   0   0   0   0   0   0   0   1   0   0   0
##   V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   0   0   1   0   1   0   1   0   0   1

“Ekta was born and brought up in Mumbai, India. She loves dogs. She is good at dunking a basketball swiftly, as well as drive a stick shift. She can watch any Tom Hanks movie on repeat.”

Ekta<-data%>%filter(data$V5=="Dog" & data$V11=="Tom Hanks" & data$V23 == 1)
Ekta
##     V1    V2          V3                V4  V5        V6           V7
## 1 5640 Pizza What dress? Yes, occasionally Dog Chocolate Right-handed
##                  V8     V9 V10       V11 V12    V13 V14 V15             V16 V17
## 1 Yes, I believe so Cooler  99 Tom Hanks  No iPhone   5     Yes, one or two  No
##    V18  V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
## 1 <NA> <NA>   1   0   0   1   0   0   0   0   0   0   0   0   0   0   0   1   0
##   V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   0   0   1   0   0   0   1   0   0   0

“Harsh Patel grew up in India. He is a big fan of Rohit Sharma, a cricketer. He hates tapioca pearls in a drink. His favorite number is 1.”

Harsh<-data %>% filter (data$V14=="1" & data$V46==1 & is.na(data$V19))
Harsh
##     V1         V2          V3                V4   V5        V6           V7
## 1 2113 bubble tea What dress? Yes, occasionally Lion Chocolate Right-handed
##              V8     V9 V10    V11 V12     V13 V14 V15             V16 V17  V18
## 1 Not 100% sure Cooler  80 Robert  No Android   1     Yes, one or two  No <NA>
##    V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37
## 1 <NA>   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0   0   1
##   V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   1   0   0   0   0   1   0   0   1

“Anushree was born and raised in India. She misses the warm weather, cricket and driving a stick shift. She would pick pizza + coke over burger + fries any day.”

Anushree <- data %>% filter (data$V9=="Warmer" & data$V23==1 & data$V46==1 & (data$V2=="Burger" | data$V2 == "Fries"))
Anushree
##     V1    V2             V3                V4  V5        V6           V7
## 1 7479 Fries Blue and black Yes, occasionally Dog Chocolate Right-handed
##              V8     V9 V10             V11 V12    V13 V14 V15               V16
## 1 Not 100% sure Warmer  10 Kiera Knightley Yes iPhone   2     Yes, most of them
##   V17  V18  V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35
## 1  No <NA> <NA>   0   0   0   1   0   0   0   0   0   0   0   0   0   0   0   0
##   V36 V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   0   0   1   0   0   0   0   0   0   0   1

“Neel, Kunj and Janish are international students from India. While one of them does not know what rolling a tongue is, the other two can do it easily. One of them is too young to know what rotary phones are, but the other two have used them before. None of them can drive stick shift. The three of them keep fighting over the thermostat and ultimately the temperature is increased due to a 2:1 majority. When offered ice cream, chocolate is everyones go to. Neel likes to look tall which is why he learnt how to walk on stilts. All three watch soccer, two of them are huge fans of ronaldo and follow teams most associated to him. Kunj is the only one of the three who can juggle, and always sits on the leftmost corner of the dining table”

Neel<-data %>% filter (data$V6=="Chocolate" & (data$V8=="Yes, and I have" | data$V8=="A what?") &  (data$V12=="Yes" | data$V12=="What?") & data$V23==0 & data$V26==1 & data$V27==0 & data$V43==1)
Neel
##     V1    V2          V3                V4   V5        V6           V7      V8
## 1 4954 Pasta What dress? Yes, occasionally Lion Chocolate Right-handed A what?
##       V9 V10       V11 V12    V13 V14         V15               V16 V17 V18
## 1 Cooler  90 Brad Pitt Yes iPhone   3 Real Madrid Yes, most of them  No Odd
##        V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
## 1 Thursday   0   0   0   0   0   0   1   0   0   0   0   0   0   0   0   0   0
##   V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   1   0   0   0   0   0   1   0   0   1
Kunj<-data %>% filter (data$V9 =="Warmer" & data$V8=="Yes, and I have" & data$V12=="Yes" & data$V23==0 & data$V6=="Chocolate" & data$V43==1 & data$V27==1)
Kunj
##     V1      V2             V3              V4    V5        V6          V7
## 1 9390 Shwarma White and gold Yes, constantly Llama Chocolate Left-handed
##                V8     V9 V10                    V11 V12    V13 V14
## 1 Yes, and I have Warmer   7 Arnold Schwarzenneger  Yes iPhone   3
##                 V15             V16                                V17  V18
## 1 Manchester United Yes, one or two No, but I'm totally doing that now <NA>
##    V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37
## 1 <NA>   0   0   1   0   1   1   0   1   0   0   0   1   0   1   0   0   0   0
##   V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   0   0   1   0   1   1   1   1   1
Janish <- data%>%filter(data$V9 =="Warmer" & data$V8 == "Yes, and I have" & data$V6=="Chocolate" & (data$V12 == "What?") & data$V27 == 0)
Janish
##     V1     V2             V3              V4    V5        V6           V7
## 1 3447 Yogurt White and gold Yes, constantly Horse Chocolate Right-handed
##                V8     V9 V10           V11   V12              V13 V14 V15 V16
## 1 Yes, and I have Warmer   4 Margot Robbie What? Other smartphone   4      No
##   V17  V18  V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35
## 1  No <NA> <NA>   1   1   1   0   1   0   0   0   0   0   0   0   0   0   0   0
##   V36 V37 V38 V39 V40 V41 V42 V43 V44 V45 V46
## 1   1   0   0   0   0   0   0   1   0   0   0