I'm going through some subsetting examples with mtcars, like here:
mtcars[mtcars$gear == 5, ]
now this returns me all the rows in mtcars where gear = 5, but how do I tell it for example to also return the rows where gear = 4 as well?
gear = 5
gear = 4
I have been looking at logical operators and such, but neither & nor | seems to work.
We can use %in% instead of ==
%in%
==
mtcars[mtcars$gear %in% c(4, 5), ]
2.1m questions
2.1m answers
60 comments
57.0k users