| is_numeric_linter {lintr} | R Documentation |
Redirect is.numeric(x) || is.integer(x) to just use is.numeric(x)
Description
is.numeric() returns TRUE when typeof(x) is double or integer –
testing is.numeric(x) || is.integer(x) is thus redundant.
Usage
is_numeric_linter()
Details
NB: This linter plays well with class_equals_linter(), which can help
avoid further is.numeric() equivalents like
any(class(x) == c("numeric", "integer")).
Tags
best_practices, consistency, readability
See Also
linters for a complete list of linters available in lintr.
Examples
# will produce lints
lint(
text = "is.numeric(y) || is.integer(y)",
linters = is_numeric_linter()
)
lint(
text = 'class(z) %in% c("numeric", "integer")',
linters = is_numeric_linter()
)
# okay
lint(
text = "is.numeric(y) || is.factor(y)",
linters = is_numeric_linter()
)
lint(
text = 'class(z) %in% c("numeric", "integer", "factor")',
linters = is_numeric_linter()
)
[Package lintr version 3.1.2 Index]