Prevent ifelse() from being used to produce TRUE/FALSE or 1/0
Source:R/redundant_ifelse_linter.R
redundant_ifelse_linter.Rd
Expressions like ifelse(x, TRUE, FALSE)
and ifelse(x, FALSE, TRUE)
are
redundant; just x
or !x
suffice in R code where logical vectors are a
core data structure. ifelse(x, 1, 0)
is also as.numeric(x)
, but even
this should only be needed rarely.
Arguments
- allow10
Logical, default
FALSE
. IfTRUE
, usage likeifelse(x, 1, 0)
is allowed, i.e., only usage likeifelse(x, TRUE, FALSE)
is linted.
See also
linters for a complete list of linters available in lintr.