recode_as_na_str {mde} | R Documentation |
Recode as NA based on string match
Description
Recode as NA based on string match
Usage
recode_as_na_str(
df,
pattern_type = "ends_with",
pattern = NULL,
case_sensitive = FALSE,
...
)
Arguments
df |
A data.frame object |
pattern_type |
One of contains', 'starts_with' or 'ends_with'. |
pattern |
A character pattern to match |
case_sensitive |
Defaults to FALSE. Patterns are case insensitive if TRUE |
... |
Other arguments to grepl |
See Also
Examples
partial_match <- data.frame(A=c("Hi","match_me","nope"), B=c(NA, "not_me","nah"))
# Replace all that end with "me" with NA
recode_as_na_str(partial_match,"ends_with","me")
# Do not recode, ie case-sensitive
recode_as_na_str(partial_match,"ends_with","ME", case_sensitive=TRUE)
[Package mde version 0.3.2 Index]