Learn R Programming

lintr (version 3.1.2)

equals_na_linter: Equality check with NA linter

Description

Check for x == NA, x != NA and x %in% NA. Such usage is almost surely incorrect -- checks for missing values should be done with is.na().

Usage

equals_na_linter()

Arguments

Tags

common_mistakes, correctness, default, robustness

See Also

linters for a complete list of linters available in lintr.

Examples

Run this code
# will produce lints
lint(
  text = "x == NA",
  linters = equals_na_linter()
)

lint(
  text = "x != NA",
  linters = equals_na_linter()
)

lint(
  text = "x %in% NA",
  linters = equals_na_linter()
)

# okay
lint(
  text = "is.na(x)",
  linters = equals_na_linter()
)

lint(
  text = "!is.na(x)",
  linters = equals_na_linter()
)

Run the code above in your browser using DataLab