Utility function to identify records for deletion
remove_deletions.Rd
Filters for records matching a given string.
Usage
remove_deletions(x, val = stringr::regex("Delete", ignore_case = TRUE))
Details
To be used within dplyr::filter()
. The function returns a logical vector
with TRUE resulting from values that are not equal to the val
argument. Also
protects from NA values.
Used within verbs such as tidyselect::all_of()
this can work effectively across all
columns in a data frame. See examples
Examples
data <- data.frame("a" = sample(c("Delete", "Keep",NA),size = 10,replace = TRUE))
data |>
dplyr::filter(dplyr::if_all(everything(), remove_deletions))
#> a
#> 1 Keep
#> 2 <NA>
#> 3 <NA>
#> 4 <NA>
#> 5 Keep
#> 6 <NA>
#> 7 <NA>