R代码性能改善
how to speed up R code
Contents
1 Your computer 3
1.1 HHD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Monitoring your computer . . . . . . . . . . . . . . . . . . . . 7
2 One R instance, one core 13
2.1 Writing your code right . . . . . . . . . . . . . . . . . . . . . 16
2.2 What part of my code is slow? . . . . . . . . . . . . . . . . . 20
2.3 Writing part of your code in C . . . . . . . . . . . . . . . . . 25
3 Using the others cores of your computer 35
3.1 Several R instances, one core for each . . . . . . . . . . . . . 35
3.2 One R instance, several cores . . . . . . . . . . . . . . . . . . 41
3.2.1 pnmath . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.2.2 pnmath0 . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2.3 doSMP . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2.4 doMC . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.2.5 parallel and snow . . . . . . . . . . . . . . . . . . . . . 48
4 Using R on a cluster 49
4.1 Unix commands . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.2 First example: Hmem . . . . . . . . . . . . . . . . . . . . . . 55
4.3 Green . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.4 Where is my cluster? . . . . . . . . . . . . . . . . . . . . . . . 62
                                        
                                    
附件列表