| all_equal_linter {lintr} | R Documentation |
Warn about invalid usage of all.equal()
Description
all.equal() returns TRUE in the absence of differences but return a
character string (not FALSE) in the presence of differences.
Usage of all.equal() without wrapping it in isTRUE() in if clauses, or
preceded by the negation operator !, are thus likely to generate unexpected
errors if the compared objects have differences.
An alternative is to use identical() to compare vector of strings or when
exact equality is expected.
Usage
all_equal_linter()
Tags
See Also
linters for a complete list of linters available in lintr.
Examples
# lints
lint(
text = 'if (all.equal(a, b)) message("equal")',
linters = all_equal_linter()
)
lint(
text = '!all.equal(a, b)',
linters = all_equal_linter()
)
lint(
text = 'isFALSE(all.equal(a, b))',
linters = all_equal_linter()
)
# okay
lint(
text = 'if (isTRUE(all.equal(a, b))) message("equal")',
linters = all_equal_linter()
)
lint(
text = '!identical(a, b)',
linters = all_equal_linter()
)
lint(
text = "!isTRUE(all.equal(a, b))",
linters = all_equal_linter()
)
[Package lintr version 3.3.0-1 Index]