So I have a data frame.
In which some specific variables may have the value of 0. But I want to delete the row only if the value of zero shows up on 3 or 4 of these specific variables.
Thank you
So I have a data frame.
In which some specific variables may have the value of 0. But I want to delete the row only if the value of zero shows up on 3 or 4 of these specific variables.
Thank you
It can be done with filter_at
by specifying the columns of interest
library(dplyr)
df1 %>%
filter_at(vars(col1, col2), all_vars(. != 0))
df1 <- data.frame(col1 = c(0, 1, 2, 3), col2 = c(1, 0, 2, 4), col3 = c(1, 1, 0, 0))