powered by
Simple function that filters a vector while helping with missing values. Replacing expression like 'x[x > 3 & !is.null(x)]'
given(.x, .y, ignore_na = FALSE)given_(.x, .y, ignore_na = TRUE)
given_(.x, .y, ignore_na = TRUE)
a vector
the vector to filter
a logical vector to filter with
should NA be removed?
if (FALSE) { x <- c(1, 2, NA, 4) x %>% given_(x >= 2) }
Run the code above in your browser using DataLab