Book Image

R High Performance Programming

Book Image

R High Performance Programming

Overview of this book

Table of Contents (17 chapters)
R High Performance Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Using Compiled Code for Greater Speed

So far, we have looked at how to optimize the computational performance of an R code. What if, after optimizing the code, it still runs too slowly? In this chapter, we will look at how to overcome the performance limitations caused by on-the-fly interpretation of an R code using a compiled code. Many CRAN packages use compiled code to offer optimum performance, so a simple way to take advantage of a compiled code is to use these packages. Sometimes, however, a specific task needs to be performed for which no package exists. It is useful to know how to write a compiled code for R in order to make R programs run faster.

We will first see how to compile R code before its execution, then we will explore how to integrate compiled languages like C/C++ into R so that we can run R programs at native CPU speed.

This chapter covers the following topics:

  • Compiling an R code before execution

  • Using compiled languages in R