Search code examples
rtidyr

removing rows with specific values


I would like to remove rows that have specific values in a given column

id     x_col
1       c4_2342
1       c4_2122 
2       c3_1212
2       c39990

I want to remove everything that has "c4"

id     x_col
2       c3_1212
2       c39990

Can someone please help?


Solution

  • Variation on @akrun:

    library(dplyr)
    library(stringr)
    
    df1 %>%
       filter(!str_detect(x_col, "c4"))