Skip to content

Files

Latest commit

 

History

History
26 lines (15 loc) · 648 Bytes

undesirable_function_linter.md

File metadata and controls

26 lines (15 loc) · 648 Bytes

Pattern: Use of undesirable function

Issue: -

Description

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().

Further Reading