mardi 4 juin 2019

How to fix a grepl function with multiple conditions and a if-statement?

I'm trying to pattern match using the grepl function with an ifelse statement but the output is all 0.

I am trying to use pattern match where if a Logo is equal to a "Taco Bell", then it matches these sets of words but not these sets of words. I have tried to use the grepl function with an ifelse statement, but it matches all mentions of the word "Taco".

ifelse(query$Logo=="Taco Bell", 
   ifelse(!grepl("d.el|'Del Taco'", query$text, ignore.case = TRUE, perl = TRUE), "0", 
     ifelse(grepl("Taco Bell", query$text, ignore.case = TRUE, perl = TRUE),"1","0")),
   NA)

The expected output is supposed to be if the Logo column is "Taco Bell" and the text column is "Taco Bell" it is pattern matched/"TRUE". If the Logo column is "Taco Bell" and text column is "Del Taco" it is not matched/"FALSE".

Aucun commentaire:

Enregistrer un commentaire