Book Image

R High Performance Programming

By : Aloysius Shao Qin Lim
Book Image

R High Performance Programming

By: Aloysius Shao Qin Lim

Overview of this book

This book is for programmers and developers who want to improve the performance of their R programs by making them run faster with large data sets or who are trying to solve a pesky performance problem.
Table of Contents (12 chapters)
11
Index

Chapter 3. Simple Tweaks to Make R Run Faster

Improving the speed of an R code does not necessarily involve advanced optimization techniques like parallelizing the code or making it run in the database. Indeed, there are a number of simple tweaks that, while not always obvious, can make R run significantly faster. In this chapter, some of these tweaks are described. By no means do they capture all possible simple means to optimize the R code. However, they constitute some of the most fundamental, and hence often-encountered, opportunities to gain some speedups.

This chapter presents these tweaks in the order of decreasing generality—the more general ones are those found in almost all R codes, regardless of their application. Each tweak is accompanied by an example code that is intentionally kept simple so as not to obscure the explanation of the intended concept with unnecessary application-specific knowledge. In all these examples, artificial datasets are generated using...