I have dataframe that is a result of
new_df <- dat %>% group_by(ID) %>% sample_frac(0.25,replace = FALSE)
data frame looks like this:
Ad.ID ID
1234 deroy
2345 deroy
4567 deroy
34567 mrroy
13467 mrroy
00024 ronde
32243 ronde
trying to filter out rows specific to certian IDs i.e. for deroy or mrroy but unable to.
exp <- new_df[new_df$ID %in%"deroy",]
using grepl was able to do it for one ID, but if I wanted to do it for two or three it doesn't work.
Please do not mark as duplicate because I Have tried all suggestions from here and few other places.
I maybe missing out some basics. Any help is appreciated.
Adding dput:
structure(list(Ad.ID = c(75856740L, 75899591L, 75904815L, 75911256L,
75911261L, 75911267L, 75911277L, 75911277L, 75911291L, 75911302L,
75905790L, 75905815L, 75905818L, 75910661L, 75914385L, 75902382L,
75902383L, 75902384L, 75902386L, 75902391L), ID = c("deroy
",
"deroy ", "deroy ",
"deroy ", "deroy ",
"deroy ", "deroy ",
"deroy ", "deroy ",
"deroy ", "deroy ",
"deroy ", "deroy ",
"deroy ", "jishuroy ",
"jishuroy ", "jishuroy ",
"jishuroy ", "jishuroy ",
"jishuroy ")), .Names = c("Ad.ID", "ID"), row.names =
c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 16L,
17L, 18L, 19L, 20L, 21L), class = "data.frame")