- 364 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Extending R
About This Book
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
Frequently asked questions
Information
R
, the principle says we should look widely to find good computational techniques to achieve our goals. If an effective solution has been implemented in a form other than R
code, providing an interface from R
may be the best approach. Part IV of the book looks at how such interfaces can be implemented and made an integral part of an R
-based project.R
and to S
before. An interface to subroutines was the way to extend the first version of S
. Subroutine interfaces have continued to be central to R
. The approach to them has changed; Chapter 16 discusses current subroutine interfaces, emphasizing an approach that provides convenience and generality through the widely used Rcpp
package.R
can come from languages focussing on computations (Python, Julia, C++
, ⋯), on data organization and management (relational DBs, Excel
, ⋯) or on display and user interactions (Java, JavaScript
, ⋯). Chapter 12 reviews interfaces in general, cites some existing packages and discusses concepts for interface programming.XR
structure. The goals of the approach are convenience, generality and consistency. Application packages can use features of the unified approach to hide the actual interface programming from their users, who program in a natural mix of functions and classes in R
. Arbitrary computations and objects in the server language are potential candidates for an interface. The structure is language-independent, with interfaces to a particular language specialized by methods and by functional extensions.Python
and Julia
languages. If your interest is specifically in one of these languages, the corresponding chapter can be read independently, referring back to Chapter 13 for details. The packages described in these chapters are available from the Github
site github.com/johnmchambers
.R
software should be considered a potential resource for extending R
. If there is some suitable software, using that rather than starting over to program something equivalent can save time, and more importantly can improve the quality of the final result.R
software as supplying us with something.Rcpp
interface to C++
.XR
package.Python
and Julia
languages using the XR
structure.R
process and evaluation model discussed in Chapter 3.C, Fortran
: These languages were and are the basic implementation languages for S
and R
. Interfaces to them are still fundamental, and in particular the .Call()
interface to C
is the basic entry point for any software linked into the R
process.C++
: Programming with C++
functions and classes supports a large body of important algorithmic software. The use of object-oriented structure and some modern programming techniques have produced a general and widely used interface package (Chapter 16).Python, Perl, JavaScript, Julia
: These are interactive languages with libraries and capabilities that may be complementary to R
. Each provides a general programming environment, in which substantial application software has been implemented, with some tendency to specialize; for example, web-based software in JavaScript
, numerical software in Julia
.Java
: This was traditionally used for serious design of web-based and other graphical interfaces. Its relatively pure OOP
structure and thorough facilities for self-describing objects and classes make it natural for similar interfaces from R
.Haskell
: The most actively used functional programming language.Excel, XML, JSON, Relational DBMS
: These languages are particularly important for many projects as repositories for data and, in the case of XML
and JSON
, as a general mechanism for representing objects to be communicated between languages.R
packages providing interfaces.R
to another language. This book is about extending R
, assuming that one starts from some programming in R
, at least in this part of a project. But the principle is itself agnostic in this respect. Many approaches to bringing good software together have been valuable.rpy2
[31] is an interface to R
from Python
that has been widely used. HaskellR
[18] is an interesting interface in which R
code snippets are inserted into a Haskell
program.Jupyter
project, https://jupyter.org
, is a web-based document-creation environment allowing code from Julia, Python
, R
and other languages to be embedded in a document. The h2o
system [25] integrates a range of statistical models with other data-science techniques supporting potentially very large applications with a combination of languages, notably R
and Java
.R
programming, useful extensions can be adapted to the project at hand.Language | Package |
C++ | Chapter 16 | |
Java | rJava | Provides classes, methods |
Python | rPython, rJython | Chapter 14 |
JavaScript | V8 | Embedded JavaScript engine |
Perl | RSPerl | On www.omegahat.net |
Julia | Chapter 15 |
JSON | rjson, jsonlite, RJSON... |
Table of contents
- Cover
- Half Title
- Title Page
- Copyright Page
- Dedication
- Table of Contents
- Preface
- I Understanding R
- II Programming with R
- III Object-Oriented Programming
- IV Interfaces
- Bibliography
- Index