Common mistakes people make in R, by Patrick Burns
Abstract
If you are using R and you think you're in hell, this is a map for you.
Contents
1 Falling into the Floating Point Trap 2
2 Growing Objects 5
3 Failing to Vectorize 9
3.1 Subscripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Vectorized if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Vectorization impossible . . . . . . . . . . . . . . . . . . . . . . . 14
4 Over-Vectorizing 15
5 Not Writing Functions 17
5.1 Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2 Simplicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.3 Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6 Doing Global Assignments 25
7 Tripping Over Object Orientation 27
7.1 S3 methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
7.2 S4 methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.3 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8 Believing It Does What is Intended 33
8.1 Ghosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8.2 Chimeras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
8.3 Devils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9 Being Unhelpful When Asking for Help 97
9.1 Read the appropriate documentation. . . . . . . . . . . . . . . . 97
9.2 Check the FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
9.3 Update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
9.4 Read the posting guide . . . . . . . . . . . . . . . . . . . . . . . . 98
9.5 Select the best list . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.6 Use a descriptive subject line . . . . . . . . . . . . . . . . . . . . 100
9.7 Clearly state your question . . . . . . . . . . . . . . . . . . . . . 101
9.8 Give a minimal, self-contained example . . . . . . . . . . . . . . 102
9.9 Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
附件列表