Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
R High Performance Programming

You're reading from  R High Performance Programming

Product type Book
Published in Jan 2015
Publisher
ISBN-13 9781783989263
Pages 176 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

R High Performance Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Understanding R's Performance – Why Are R Programs Sometimes Slow? Profiling – Measuring Code's Performance Simple Tweaks to Make R Run Faster Using Compiled Code for Greater Speed Using GPUs to Run R Even Faster Simple Tweaks to Use Less RAM Processing Large Datasets with Limited RAM Multiplying Performance with Parallel Computing Offloading Data Processing to Database Systems R and Big Data Index

Implementing data parallel algorithms


Several R packages allow code to be executed in parallel. The parallel package that comes with R provides the foundation for most parallel computing capabilities in other packages. Let's see how it works with an example.

This example involves finding documents that match a regular expression. Regular expression matching is a fairly computational expensive task, depending on the complexity of the regular expression. The corpus, or set of documents, for this example is a sample of the Reuters-21578 dataset for the topic corporate acquisitions (acq) from the tm package. Because this dataset contains only 50 documents, they are replicated 100,000 times to form a corpus of 5 million documents so that parallelizing the code will lead to meaningful savings in execution times.

library(tm)
data("acq")
textdata <- rep(sapply(content(acq), content), 1e5)

The task is to find documents that match the regular expression \d+(,\d+)? mln dlrs, which represents monetary...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}