Extending R  book cover
1st Edition

Extending R

ISBN 9781498775717
Published May 24, 2016 by Chapman and Hall/CRC
382 Pages 7 B/W Illustrations


FREE Standard Shipping
SAVE $14.99
was $74.95
USD $59.96

Prices & shipping based on shipping country


Book Description

Up-to-Date Guidance from One of the Foremost Members of the R Core Team

Written by John M. Chambers, the leading developer of the original S software, Extending R covers key concepts and techniques in R to support analysis and research projects. It presents the core ideas of R, provides programming guidance for projects of all scales, and introduces new, valuable techniques that extend R.

The book first describes the fundamental characteristics and background of R, giving readers a foundation for the remainder of the text. It next discusses topics relevant to programming with R, including the apparatus that supports extensions. The book then extends R’s data structures through object-oriented programming, which is the key technique for coping with complexity. The book also incorporates a new structure for interfaces applicable to a variety of languages.

A reflection of what R is today, this guide explains how to design and organize extensions to R by correctly using objects, functions, and interfaces. It enables current and future users to add their own contributions and packages to R.


A 2017 Choice Outstanding Academic Title

Table of Contents

Understanding R
Objects, Functions and Interfaces
Three Principles
Everything is an Object
Everything is a Function Call
Interfaces are Part of R
Functional Programming
Object-Oriented Programming

Computational Methods
The First Version of S
Functional, Object-Based S
R Arrives and Evolves
Evolution of Object-Oriented Programming
Functional OOP in S and R
S4 and R

R in Operation
Objects and References
Function Calls
The R Evaluator

Programming with R
Small, Medium and Large

Functional Programming and R
Assignments and Replacements
Computing on the Language
Interfaces and Primitives
Getting it to Run Faster

Types and Attributes
Object Management
Reference Objects; Environments

Understanding Packages
Installing a Package
Loading and Attaching a Package
Sharing your Package

In the Large

Object-Oriented Programming
Classes and Methods in R

OOP Software in R
Functional and Encapsulated OOP
Creating Classes in R
Creating Methods in R
Example: Classes for Models

Functional OOP in R
Functional OOP in Extending R
Defining Classes
Defining Methods and Generic Functions
Classes and Methods in an R Package
Functional Classes in Detail
Generic Functions in Detail
Functional Methods in Detail
S3 Methods and Classes

Encapsulated OOP in R
The Structure of Encapsulated OOP
Using Encapsulated OOP
Defining Reference Classes
Fields in Reference Classes
Methods in Reference Classes
Functional Methods for Reference Classes

Understanding Interfaces
Available Interfaces
Subroutines and Evaluators
Server Language Software
Server Language Computations
Server Language Object References
Data Conversion
Interfaces for Performance

The XR Structure for Interfaces
The XR Interface Structure
Evaluator Objects and Methods
Application Programming
Specializing to the Server Language
Proxy Objects
Proxy Functions and Classes
Data Conversion

An Interface to Python
R and Python
Python Computations
Python Programming
Python Functions
Python Classes
Data Conversion

An Interface to Julia
R and Julia
Julia Computations
Julia Programming
Julia Functions
Julia Types
Data Conversion

Subroutine Interfaces
R, Subroutines and C++
C++ Interface Programming
C++ Functions
C++ Classes
Data Conversion



View More



John M. Chambers is a consulting professor in the Department of Statistics at Stanford University. He previously worked at Bell Labs for 40 years, where he contributed to major research and management in statistical computing and related fields. He was the first statistician to be named a Bell Labs Fellow.

Chambers is best known for the creation and extension of the S software, the predecessor to today’s very popular R. He has continued to contribute essential new directions to R. In 1999, he was honored with the ACM Software System Award, which noted that "S has forever altered the way people analyze, visualize, and manipulate data."

He is a board member of the R Foundation and the R Consortium; a fellow of the ASA, the IMS, and the AAAS; and an elected member of the ISI. He is the author or co-author of nine books, including the first comprehensive book on computational methods for statistics.


"Chambers, a consulting professor in the Department of Statistics at Stanford University, indicates that the purpose of this book is to encourage and help individuals develop extensions to the R software. Obviously, one must have experience using R and ideas for extensions that he or she would like to make, such as adding some functions or developing packages of different degrees of sophistication. The book contains three fundamental principles: every element that exists within R is an 'object,' all elements that happen within R are a 'function' call, and 'interfaces' to other software are part of R. These principles are then expanded in sections about ideas and history, aspects of programming in R, object-oriented programming, and interfaces from R to other software. As Chambers is the creator of the S software (the predecessor of R), any of his works are considered important and should be acquired by all statistical science libraries. This book will be a valuable guide for individuals who wish to develop their own extensions to R, whether at a modest or a more ambitious level.

Summing Up: Highly recommended. Lower-division undergraduates and above; faculty and professionals."

~R. Bharath, Northern Michigan University

". . . Chambers provides valuable insight into some of the thinking that led to major contributions to R’s development. For example, one section is divided thoughtfully into three themes, namely, programming in the small, in the medium, and in the large. Each theme is used to introduce and illustrate different aspects of the language, from the point of view of the kinds of activities that cluster within the themes, and here the book really shines. It is a pleasure to see how a crafter of tools thinks deeply about how the tool will be used."

~Andrew Robinson, University of Melbourne

 "Doug Bates once said to me that 'There’s no doubt about John Chambers. He can see much further than the rest of us.' This latest book is yet another illustration of that incisive observation. It is fundamentally a book about perspectives and strategies. It gives a deep insight into the R landscape, its background and structure, and shows how users can work with R when they need to extend its facilities."

~Biometrics, June 2017


"This book is a must-have for anyone with a deep interest in statistical computing . . . you will learn some of the theory that underpins R, and see the directions in which you can extend it to solve your problems . . . it does give you powerful ways of thinking about programming on a large scale that will pay off as you tackle more ambitious projects."~Hadley Wickham, Journal of the American Statistical Association


" . . . any new book by John Chambers, the main developer of the original S language from which R derives, commands particular attention. . . Experienced R programmers will want a copy. R users seeking a deeper understanding of the internal structure of the language will also benefit, especially regarding aspects of functional programming and object-oriented computations.

~Christian Kleiber, Stat Papers