Take a look at the filter
function in the package dplyr
. Subset rows using column values — filter • dplyr
Here's a tiny example of how you would do this but if you need more help. Please look into providing a reproducible example (FAQ: How to do a minimal reproducible example ( reprex ) for beginners):
library(tidyverse)
subsetteddata <- dataset %>%
filter(variablename %in% c("football", "camera", "car", "plane"))