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.
redundant_ifelse_linter(allow10 = FALSE)
Logical, default FALSE
. If TRUE
, usage like
ifelse(x, 1, 0)
is allowed, i.e., only usage like
ifelse(x, TRUE, FALSE)
is linted.
best_practices, consistency, efficiency
linters for a complete list of linters available in lintr.