To filter the data frame by values in a column, you can do the following:
studentdata[studentdata$Drink == 'water',]
Student Height Gender Shoes Number Dvds ToSleep WakeUp Haircut Job Drink
1 1 67.00 female 10 5 10.0 -2.5 5.5 60.00 30.0 water
4 4 61.00 female 3 6 40.0 2.0 8.5 10.00 0.0 water
6 6 63.00 female NA 3 5.0 1.0 8.5 25.00 0.0 water
7 7 61.00 female 12 3 53.0 1.5 7.5 35.00 20.0 water
9 9 66.00 female 30 3 40.0 -0.5 7.0 30.00 25.0 water
12 12 63.00 female 20 4 60.0 -1.0 7.0 38.00 0.0 water
16 16 65.00 female 40 7 50.0 -0.5 7.0 15.00 0.0 water
17 17 62.00 female 8 7 NA 0.0 8.5 40.00 0.0 water
19 19 71.00 male 6 7 0.0 0.5 7.5 12.00 12.5 water
20 20 64.00 female 4 7 8.0 -1.5 7.5 30.00 16.0 water
21 21 71.00 male 9 7 12.0 1.5 8.0 0.00 12.0 water
22 22 61.00 female 20 5 10.0 1.5 7.5 20.00 5.0 water
.
.
.
You can also use the filter function from the dplyr package as follows:
library(dplyr)
filter(studentdata, Drink == "water")
Student Height Gender Shoes Number Dvds ToSleep WakeUp Haircut Job Drink
1 1 67.00 female 10 5 10.0 -2.5 5.5 60.00 30.0 water
2 4 61.00 female 3 6 40.0 2.0 8.5 10.00 0.0 water
3 6 63.00 female NA 3 5.0 1.0 8.5 25.00 0.0 water
4 7 61.00 female 12 3 53.0 1.5 7.5 35.00 20.0 water
5 9 66.00 female 30 3 40.0 -0.5 7.0 30.00 25.0 water
6 12 63.00 female 20 4 60.0 -1.0 7.0 38.00 0.0 water
7 16 65.00 female 40 7 50.0 -0.5 7.0 15.00 0.0 water
8 17 62.00 female 8 7 NA 0.0 8.5 40.00 0.0 water
9 19 71.00 male 6 7 0.0 0.5 7.5 12.00 12.5 water
10 20 64.00 female 4 7 8.0 -1.5 7.5 30.00 16.0 water