recode_as_na_str: Recode as NA based on string match

Description Usage Arguments See Also Examples

View source: R/recode_as_na_str.R

Description

Recode as NA based on string match

Usage

1
2
3
4
5
6
7
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

recode_as_na recode_as_na_if

Examples

1
2
3
4
5
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)

mde documentation built on Feb. 10, 2022, 5:08 p.m.

Related to recode_as_na_str in mde...