How can create a subset from the data ToothGrowth
len supp dose
1 4.2 VC 0.5
2 11.5 VC 0.5
3 7.3 VC 0.5
...
29 23.3 VC 2.0
30 29.5 VC 2.0
31 15.2 OJ 0.5
32 21.5 OJ 0.5
. . .
58 27.3 OJ 2.0
59 29.4 OJ 2.0
60 23.0 OJ 2.0
by choosing all records where dose supplement type (supp )is OJ and assign them to variable ans?
I tried this:
ans <- ToothGrowth[ToothGrowth$supp=="OJ"]
and this:
ans <- ToothGrowth[ToothGrowth$supp=="OJ",]
but apparently neither of those are correct.
I would be really grateful for advice.