I have to filter a data frame using as criterion those row in which is contained the string RTB
.
I'm using dplyr
.
d.del <- df %>%
group_by(TrackingPixel) %>%
summarise(MonthDelivery = as.integer(sum(Revenue))) %>%
arrange(desc(MonthDelivery))
I know I can use the function filter
in dplyr
but I don't exactly how to tell it to check for the content of a string.
In particular I want to check the content in the column TrackingPixel
. If the string contains the label RTB
I want to remove the row from the result.
Best Answer
The answer to the question was already posted by the @latemail in the comments above. You can use regular expressions for the second and subsequent arguments of
filter
like this:Since you have not provided the original data, I will add a toy example using the
mtcars
data set. Imagine you are only interested in cars produced by Mazda or Toyota.If you would like to do it the other way round, namely excluding Toyota and Mazda cars, the
filter
command looks like this: