Ive only been using R for a short period of time and this is my first post so apologies if i have tagged/catagorised wrong.
My problem is that i have to create a new variable depending on what words are within other variables. Some of these are very specific e.g. if UTM.source = "PR" then Channel = "PR". However some are more complex e.g. If UTM. source or UTM. medium contain "print" but don't contain "local" then Channel = "DM". I have been trying to use a nested ifelse statement with grepl && !grepl but no variations are working correctly. I should give my whole code, but here are a few lines to show roughly what i have been trying. I am getting no error messages but the output isnt giving me what i need.
I suggest that you use the case_when() function from dplyr instead of nested ifelse() functions and that you use parentheses to designate the desired logic. I also used str_detect() in place of grepl but that isn't necessary. I am not sure I implemented the logic you intend.