Here is my data:
df <- tibble::tribble(
~A, ~B, ~C, ~D,
2L, "a", "e", 2L,
4L, "a", "f", NA_integer_,
4L, "b", "g", NA_integer_,
4L, "b", "h", NA_integer_
)
df$B <- as.factor(df$B)
df$A <- as.factor(as.character(df$A))
Here is my filter condition as a character:
remove2 <- "as.integer(A)!=2L"
I just want remove observations with A==2, but instead the following code keeps it, why?
df %>% dplyr::filter_(remove2)
I want to use filter_ as it accepts the condition as a character. If you can suggest filter (without underscore version) and take character as a condition, that will also work.