I'm trying to create a dplyr pipeline to filter on
Imagine a data frame jobs
, where I want to filter out the most-senior positions from the titles
column:
titles
Chief Executive Officer
Chief Financial Officer
Chief Technical Officer
Manager
Product Manager
Programmer
Scientist
Marketer
Lawyer
Secretary
R code for filtering them out (up to 'Manager') would be...
jobs %>%
filter(!str_detect(title, 'Chief')) %>%
filter(!str_detect(title, 'Manager')) ...
but I want to still keep "Program Manager" in the final filtering to produce a new data frame with all of the "lower level jobs" like
Product Manager
Programmer
Scientist
Marketer
Lawyer
Secretary
Is there a way to specify the str_detect() filter on a given value EXCEPT for one particular string?
Assume that the data frame's column has 1000s of roles, with various string combinations including "Manager," but there will always be a filter on a specific exception.