View source: R/ifelse_censor_linter.R
ifelse_censor_linter | R Documentation |
ifelse()
where pmin()
or pmax()
is more appropriateifelse(x > M, M, x)
is the same as pmin(x, M)
, but harder
to read and requires several passes over the vector.
ifelse_censor_linter()
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)
.
best_practices, efficiency
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "ifelse(5:1 < pi, 5:1, pi)",
linters = ifelse_censor_linter()
)
lint(
text = "ifelse(x > 0, x, 0)",
linters = ifelse_censor_linter()
)
# okay
lint(
text = "pmin(5:1, pi)",
linters = ifelse_censor_linter()
)
lint(
text = "pmax(x, 0)",
linters = ifelse_censor_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.