ABSTRACT

This chapter explains selected programming topics for more experienced R users. The selection of topics is by no means comprehensive, but rather a collection of information that tends to be helpful for developing computational programs, such as benchmarking code or finding the source code of functions. To improve the execution time of R code, it is helpful to compare the timings of different expressions that are equivalent ways to perform a computing task. Often a small chunk of code is responsible for a large chunk of computing time, particularly if the code is executed repeatedly within a program. The microbenchmark package provides a convenient utility function microbenchmark that performs sub-millisecond accurate timing of one or more expressions. The rbenchmark package provides a function benchmark, which is a convenient wrapper around the R system. The benchmark function performs a similar timing experiment as microbenchmark.