library(dplyr)
#removing what you do not want
df %>%
filter(!ans %in% c("Don't know", "Refuse"))
#keeping what you do want
df %>%
filter(ans == "Yes" | ans == "No" )
в базе R один из множества вариантов может быть:
df[!df$ans %in% c("Don't know", "Refuse"), ]
данные
df <- data.frame(id = c(1, 2, 8, 9),
ans = c("Yes", "No", "Don't know", "Refuse"))