ABSTRACT

This book offers solutions to all 284 exercises in Advanced R, Second Edition. All the solutions have been carefully documented and made to be as clear and accessible as possible. Working through the exercises and their solutions will give you a deeper understanding of a variety of programming challenges, many of which are relevant to everyday work. This will expand your set of tools on a technical and conceptual level. You will be able to transfer many of the specific programming schemes directly and will discover far more elegant solutions to everyday problems.

Features:

  • When R creates copies, and how it affects memory usage and code performance
  • Everything you could ever want to know about functions
  • The differences between calling and exiting handlers
  • How to employ functional programming to solve modular tasks
  • The motivation, mechanics, usage, and limitations of R's highly pragmatic S3 OO system
  • The R6 OO system, which is more like OO programming in other languages
  • The rules that R uses to parse and evaluate expressions
  • How to use metaprogramming to generate HTML or LaTeX with elegant R code
  • How to identify and resolve performance bottlenecks

 

part I|84 pages

Foundations

chapter 2Chapter 2|14 pages

Names and values

chapter Chapter 3|14 pages

Vectors

chapter Chapter 4|6 pages

Subsetting

chapter Chapter 5|4 pages

Control flow

chapter Chapter 6|20 pages

Functions

chapter Chapter 7|12 pages

Environments

chapter Chapter 8|12 pages

Conditions

part II|38 pages

Functional programming

chapter 86Chapter 9|14 pages

Functionals

chapter Chapter 10|14 pages

Function factories

chapter Chapter 11|8 pages

Function operators

part III|52 pages

Object-oriented programming

chapter 124Chapter 13|24 pages

S3

chapter Chapter 14|12 pages

R6

chapter Chapter 15|14 pages

S4

part IV|70 pages

Metaprogramming

chapter 176Chapter 18|18 pages

Expressions

chapter Chapter 19|14 pages

Quasiquotation

chapter Chapter 20|14 pages

Evaluation

chapter Chapter 21|22 pages

Translating R code

part V|38 pages

Techniques

chapter 246Chapter 23|6 pages

Measuring performance

chapter Chapter 24|14 pages

Improving performance

chapter Chapter 25|16 pages

Rewriting R code in C++