Why learn R? Because it's rapidly becoming the standard for developing statistical software. R in a Nutshell provides a quick and practical way to learn this increasingly popular open source language and environment. You'll not only learn how to program in R, but also how to find the right user-contributed R packages for statistical modeling, visualization, and bioinformatics.

The author introduces you to the R environment, including the R graphical user interface and console, and takes you through the fundamentals of the object-oriented R language. Then, through a variety of practical examples from medicine, business, and sports, you'll learn how you can use this remarkable tool to solve your own data analysis problems.

Understand the basics of the language, including the nature of R objects

Learn how to write R functions and build your own packages

Work with data through visualization, statistical analysis, and other methods

Explore the wealth of packages contributed by the R community

Become familiar with the lattice graphics package for high-level data visualization

Learn about bioinformatics packages provided by Bioconductor

"I am excited about this book. R in a Nutshell is a great introduction to R, as well as a comprehensive reference for using R in data analytics and visualization. Adler provides 'real world' examples, practical advice, and scripts, making it accessible to anyone working with data, not just professional statisticians."

R Basics

Chapter 1 Getting and Installing R

R Versions

Getting and Installing Interactive R Binaries

Chapter 2 The R User Interface

The R Graphical User Interface

The R Console

Batch Mode

Using R Inside Microsoft Excel

Other Ways to Run R

Chapter 3 A Short R Tutorial

Basic Operations in R

Functions

Variables

Introduction to Data Structures

Objects and Classes

Models and Formulas

Charts and Graphics

Getting Help

Chapter 4 R Packages

An Overview of Packages

Listing Packages in Local Libraries

Loading Packages

Exploring Package Repositories

Custom Packages

The R Language

Chapter 5 An Overview of the R Language

Expressions

Objects

Symbols

Functions

Objects Are Copied in Assignment Statements

Everything in R Is an Object

Special Values

Coercion

The R Interpreter

Seeing How R Works

Chapter 6 R Syntax

Constants

Operators

Expressions

Control Structures

Accessing Data Structures

R Code Style Standards

Chapter 7 R Objects

Primitive Object Types

Vectors

Lists

Other Objects

Attributes

Chapter 8 Symbols and Environments

Symbols

Working with Environments

The Global Environment

Environments and Functions

Exceptions

Chapter 9 Functions

The Function Keyword

Arguments

Return Values

Functions As Arguments

Argument Order and Named Arguments

Side Effects

Chapter 10 Object-Oriented Programming

Overview of Object-Oriented Programming in R

Object-Oriented Programming in R: S4 Classes

Old-School OOP in R: S3

Chapter 11 High-Performance R

Use Built-in Math Functions

Use Environments for Lookup Tables

Use a Database to Query Large Data Sets

Preallocate Memory

Monitor How Much Memory You Are Using

Functions for Big Data Sets

Parallel Computation with R

High-Performance R Binaries

Working with Data

Chapter 12 Saving, Loading, and Editing Data

Entering Data Within R

Saving and Loading R Objects

Importing Data from External Files

Exporting Data

Importing Data from Databases

Chapter 13 Preparing Data

Combining Data Sets

Transformations

Binning Data

Subsets

Summarizing Functions

Data Cleaning

Finding and Removing Duplicates

Sorting

Chapter 14 Graphics

An Overview of R Graphics

Graphics Devices

Customizing Charts

Chapter 15 Lattice Graphics

History

An Overview of the Lattice Package

High-Level Lattice Plotting Functions

Customizing Lattice Graphics

Low-Level Functions

Statistics with R

Chapter 16 Analyzing Data

Summary Statistics

Correlation and Covariance

Principal Components Analysis

Factor Analysis

Bootstrap Resampling

Chapter 17 Probability Distributions

Normal Distribution

Common Distribution-Type Arguments

Distribution Function Families

Chapter 18 Statistical Tests

Continuous Data

Discrete Data

Chapter 19 Power Tests

Experimental Design Example

t-Test Design

Proportion Test Design

ANOVA Test Design

Chapter 20 Regression Models

Example: A Simple Linear Model

Details About the lm Function

Subset Selection and Shrinkage Methods

Nonlinear Models

Survival Models

Smoothing

Machine Learning Algorithms for Regression

Chapter 21 Classification Models

Linear Classification Models

Machine Learning Algorithms for Classification

Chapter 22 Machine Learning

Market Basket Analysis

Clustering

Chapter 23 Time Series Analysis

Autocorrelation Functions

Time Series Models

Chapter 24 Bioconductor

An Example

Key Bioconductor Packages

Data Structures

Where to Go Next

Appendix R Reference

base

boot

class

cluster

codetools

foreign

grDevices

graphics

grid

KernSmooth

lattice

MASS

methods

mgcv

nlme

nnet

rpart

spatial

splines

stats

stats4

survival

tcltk

tools

utils

Bibliography

Colophon

Joseph Adler

Joseph Adler has many years of experience in data mining and data analysis at companies including DoubleClick, American Express, and VeriSign. He graduated from MIT with an Sc.B and M.Eng in Computer Science and Electrical Engineering from MIT. He is the inventor of several patents for computer security and cryptography, and the author of Baseball Hacks. Currently, he is a senior data scientist at LinkedIn.

The animal on the cover of R in a Nutshell is a harpy eagle (Harpia harpyja). Black feathers line the top half of the bird, while white feathers mostly make up the balance, although the underside of its wings may be striped black-and-white. Unlike other species of birds, male and female harpy eagles appear virtually identical.

These eagles-the most powerful, carnivorous raptors in the Americas-typically inhabit tropical rain forests. They prey upon animals that live in trees: sloths, monkeys, opossums, and even other birds, such as macaws.

The eagle is named after the harpies of ancient Greek mythology, female wind spirits who were said to be human from the chest to their ankles and eagle from the neck up. Mythological harpies tormented people as they carried them to the underworld with their clawed feet; perhaps similarly, harpy eagles' talons violently pierce and subdue their prey before the eagles carry them back to their nests.

Harpy eagles also inspire modern-day life: the eagle is the national bird of Panama and is pictured on the country's coat of arms. The bird also inspired the design of Fawkes the Phoenix in the Harry Potter film series.

The cover image is from Cassell's Natural History. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSansMonoCondensed.

I am a complete newbie to data analytics and got introduced to the subject via my lecturer at university setting an assignment to use Revolution Analytics and Data mine some data sets... I found the initial chapters very easy to work through, howvere i find it really challenging when i got to trying to install the package 'nutshell' to work through some examples and steps... i have had zero luck and have downladed from the link mentioned in another review and still get multiple different error messages, the latest being -

Error in library(nutshell) : package 'nutshell' does not have a NAMESPACE and should be re-installed

Other than getting these errors, it seems like a helpful book to gain initial insights but can be very frustrating at the same time.

I just got this book, and haven't studied it yet, but just to respond to the two previous reviews, I had no trouble downloading and installing the "nutshell" package (library) that contains the sample data sets. From the link provided on the O'Reilly page, I downloaded the .tgz file, then in Mac OS X version of R used Packages Data -> Package Installer to load the package as a "local binary package." Then used the R command library(nutshell).

The book seems to be clear but it is annoying when the examples given cannot be used because the "nutshell" package is not available. This happens with many technical books and makes them frustrating to use.

Bottom LineNo, I would not recommend this to a friend

Merchant response: Hi,

Thank you for writing us about "R in a Nutshell." The nutshell package can be downloaded at http://examples.oreilly.com/9780596801717/

If you encounter any problems with the example package, please feel free to contact our book technical support group at booktech@oreilly.com.

The book is not bad and I like it as a reference (not something to work through from A-Z). Sometimes, it's too obvious that the author tried to squeeze in too much so some little sections are not helpful: they indicate that a certain functionality is available, but nothing else - in such cases less (different sections) would have been more (in terms of readability). Real downer: the package doesn't install, neither on R 2.10 nor on R 2.12 (for Win 7).

I am very new to R, and have been reading this book for roughly a week now. The good part about this book is the overall organization. It's pretty easy to find what you're looking for - it's a desktop reference. Unfortunately, learning how to use R is a bit hard from this book. You could go the route of page 1 in learning the basic syntax, then eventually going into graphics and analysis of data - but quite honestly most books I've seen rather go with small projects to give the feel for something then jump into the details. I found I had to go to a tutorial first to get a general feel about what R can do, before diving too far into the book. The largest issue I have with the book is that it contains some typos. I found the most confusing was the constant reference to outputting a pdf (using png..). I kept getting errors trying to open the PDF, and through some googling I found that he actually likely meant the pdf command, where png requires a png extension. I feel like kinda an idiot now for not seeing it earlier, but it's little things like this you'll need to be careful of. Another issue I have with the book is the constant jumping around from various data sets. Some data sets aren't even explained well beforehand on commands done against them. There's a bit of a "leap of faith" about what x is set to currently as operations are done to it. Overall, I think the book is good, especially for reference despite the typos and data descriptions.

This book is a very good introduction to the R programming language.R is a free, general purpose programming language(with a strong support for doing statistics).The language has its idiosyncrasies. For example, the assignment operator is denoted by a reverse arrow (x<-2); this book does a pretty good job of explaining all these in detail. Once you get past these details, you will find that R is a pretty versatile language. Let us take an example (source: [@]). The following code installs the quantmod packageand then displays the stock of Apple along with Bollinger Bands ([@]).install.packages("quantmod") # installs the package quantmodlibrary(quantmod) # loads the packagegetSymbols("AAPL") # load Apple's datachartSeries(AAPL) # Create financial chartsaddBBands() # Add the Bollinger Bands.One of the best parts of R is huge support of libraries for doing commercial grade statistics and the plots/graphs produced by R are of high quality.Though I didn't get a chance to try it out, there is a package called RPy which is a Python interface to the R programming language. More details can be found here: [@]you are mathematically inclined, definitely check this book out. Once you learn R, you can use it anywhere/anytime without ever paying a license fee.

I've been looking for a good introduction to R for a long time now, and this book really does do remarkable job of introducing you to the basics, while fleshing out the finer details of the language.

However, I feel it is badly let down by frequent typos and omissions. By way of example, on page 318 the reader is instructed to split a data set on a date using "cut":

bwplot(price~cut(saledate,"month"),data=sanfrancisco.home.sales)

This simply will not work, as cut expects a numeric value; the correct method would be to use "cut.Date". It's fairly obvious what has gone wrong, but that's not always the case. Novice users really shouldn't have to chase these, all too frequent, mistakes up.

All in all, a handy textbook that I would recommend, albeit with the caveat you'll occasionally need to search round to find what the author should have written. Errata can't come soon enough in my opinion...