View source: R/recode_as_na_str.R
recode_as_na_str | R Documentation |
Recode as NA based on string match
recode_as_na_str( df, pattern_type = "ends_with", pattern = NULL, case_sensitive = FALSE, ... )
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 |
recode_as_na
recode_as_na_if
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.