View source: R/all_equal_linter.R
| all_equal_linter | R Documentation |
all.equal()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.
all_equal_linter()
common_mistakes, robustness
linters for a complete list of linters available in lintr.
# 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()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.