notin

NoteAdded in 0.6.0

What it does

Checks for usage of !x %in% y or !(x %in% y) and recommends using %notin% instead.

Why is this bad?

Starting from R 4.6.0, the %notin% operator is available in base R. Using %notin% makes the intent clearer than wrapping %in% in a negation.

Example

!x %in% choices

if (!(x %in% choices)) {
  print("x is not in choices")
}

Use instead:

x %notin% choices

if (x %notin% choices) {
  print("x is not in choices")
}

References

See ?match