Pattern: Use of undesirable function
Issue: -
Avoid functions that return different types of output. E.g. sapply
is not type safe, it returns a different data type depending on the input, and on the input length. In particular:
sapply(1:10, paste)
returns a character vector, and
sapply(integer(), paste)
returns a list. This often leads to errors in edge cases. A better alternative is vapply
.
Avoid functions that change global state: setwd()
, options()
, par()
, sink()
.