Grepl command not working?

Example Df1

OK BUSY stext
Y N Some text to check
Y N Other text to check
N N Some text to check
Y N Some text to check

Why does this work fine

df1 <- df1 %>% filter(grepl("Y",OK,"N",BUSY))
df1 <- df1 %>% filter(grepl(stext,toupper("Some text to check")))

Result

OK BUSY stext
Y N Some text to check
Y N Some text to check

But this doesnt if I group all the searches together

df1 <- df1 %>% filter(grepl("Y",OK,"N",BUSY,stext,toupper("Some text to check")))

OK BUSY stext
Y N Some text to check
Y N Other text to check
Y N Some text to check

grepl does not take an arbitrary list of repeating patterns and texts to search in.

grepl(pattern, x, ignore.case = FALSE, perl = FALSE,
      fixed = FALSE, useBytes = FALSE)

if you perceived

df1 <- df1 %>% filter(grepl("Y",OK,"N",BUSY))

as having worked, it would only have done so by accident, because the Y/OK is the functional part in your example. and the N/Bus is not observed to make a difference

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.