Вы можете использовать функцию %in%
, чтобы остаться со всеми элементами, которые соответствуют вектору.
# Dummy data that may be similar to your original data
df = data.frame(var = rep(c("Practice(1)", "Practice(2)", "Test(1)", "Test(2)", "closing screen"),each = 5),
var2 = rnorm(25,10,1))
#Create a vector which contains the levels of var that you are interested in
varsIwant <-c("Practice(1)", "Practice(2)", "closing screen")
#Stay only with the rows where its var level matches any of the varsIwant vector
df[df$var %in% varsIwant,]