I have a simple data frame that looks like this:
x <- c(\"aa\", \"aa\", \"aa\", \"bb\", \"cc\", \"cc\", \"cc\")
y <- c(101, 102, 113, 201, 202, 344, 40
You need to double check the documentations for grepl and filter.
For grep/grepl you have to also supply the vector that you want to check in (y in this case) and filter takes a logical vector (i.e. you need to use grepl). If you want to supply an index vector (from grep) you can use slice instead.
df %>% filter(!grepl("^1", y))
Or with an index derived from grep:
df %>% slice(grep("^1", y, invert = TRUE))
But you can also just use substr because you are only interested in the first character:
df %>% filter(substr(y, 1, 1) != 1)
With a combination of dplyrand stringr (to stay within the tidyverse), you could do :
df %>% filter(!str_detect(y, "^1"))
This works because str_detect returns a logical vector.