Block usage of ifelse where pmin or pmax is more appropriate
Source:R/ifelse_censor_linter.R
ifelse_censor_linter.Rd
ifelse(x > M, M, x)
is the same as pmin(x, M)
, but harder
to read and requires several passes over the vector.
Details
The same goes for other similar ways to censor a vector, e.g.
ifelse(x <= M, x, M)
is pmin(x, M)
,
ifelse(x < m, m, x)
is pmax(x, m)
, and
ifelse(x >= m, x, m)
is pmax(x, m)
.
See also
linters for a complete list of linters available in lintr.