literal_coercion_linter {lintr} | R Documentation |
as.integer(1)
is the same as 1L
but the latter is more concise and
gets typed correctly at compilation.
literal_coercion_linter()
The same applies to missing sentinels like NA
– typically, it is not
necessary to specify the storage type of NA
, but when it is, prefer
using the typed version (e.g. NA_real_
) instead of a coercion
(like as.numeric(NA)
).
best_practices, consistency, efficiency
linters for a complete list of linters available in lintr.