View source: R/is_numeric_linter.R
| is_numeric_linter | R Documentation |
is.numeric(x) || is.integer(x) to just use is.numeric(x)is.numeric() returns TRUE when typeof(x) is double or integer –
testing is.numeric(x) || is.integer(x) is thus redundant.
is_numeric_linter()
NB: This linter plays well with class_equals_linter(), which can help
avoid further is.numeric() equivalents like
any(class(x) == c("numeric", "integer")).
best_practices, consistency, readability
linters for a complete list of linters available in lintr.
# 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()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.