scalar_in_linter: Block usage like x %in% "a"

View source: R/scalar_in_linter.R

scalar_in_linterR Documentation

Block usage like x %in% "a"

Description

vector %in% set is appropriate for matching a vector to a set, but if that set has size 1, == is more appropriate. ⁠%chin%⁠ from {data.table} is matched as well.

Usage

scalar_in_linter()

Details

scalar %in% vector is OK, because the alternative (any(vector == scalar)) is more circuitous & potentially less clear.

Tags

best_practices, consistency, efficiency, readability

See Also

linters for a complete list of linters available in lintr.


lintr documentation built on Nov. 7, 2023, 5:07 p.m.