R can be confusing when you're first starting out, especially when you don't have any experience in programming. There's a lot of documentation online, and package developers do a decent job at providing examples on how to use their work in your code, but that stuff is not always easy to find. It's easy if you know the name of the package or function you're looking for. However, most of the time you just know what you want to do—like sort a data frame or test a regression model—and not the name of a package.

The *R Cookbook* by developer Paul Teetor might be your answer.

## Overview

From the book description:

This collection of concise, task-oriented recipes makes you productive with R immediately, with solutions ranging from basic tasks to input and output, general statistics, graphics, and linear regression.

There are 14 chapters and around 400 pages. One third covers the basics of R, such as setting variables; one half covers analysis tools such hypothesis testing and linear regression; the rest covers miscellaneous topics. There's one chapter on creating graphics.

## The Insides

Those who have used other O'Reilly cookbooks will recognize the format right away. Sections are organized by recipe with a problem, solution, and discussion. Most recipes are pretty short, around one or two pages.

In short, *R Cookbook* is basically what I expected. This is a good thing, as O'Reilly cookbooks are usually pretty useful. The recipes are straightforward to follow and the text is an easy read. There's some discussion at the beginning of each chapter about statistical methods, such as what p-values mean, but don't expect a full-on guide on statistical analysis (not that it claims to be one).

What this book will provide are steps that can help you with the early stages of getting up and running to the more advanced functions for probability, general statistics, and time series analysis.

## Bottom Line

For those who already use R, the *R Cookbook* can be a handy reference when Google lets you down. I imagine those who are familiar with statistical methods but use different software like SAS will also find this useful. If, however, you're looking for a book that's more visualization-based or you're new to statistics, you will probably want to look elsewhere.

Is there a better introductory book? I use STATA at work and have a basic social science statistical background but have been meaning to start learning R for some time. I’ve played around with it a bit, but could probably use some structured lessons from a book. Any recommendations would be appreciated, thanks!

I haven’t used it myself, but I’ve heard good things about

R in a Nutshellby Joseph Adler.I haven’t read the R Cookbook yet, so I can’t do a comparison, but if you have something very specific in mind it could be worth while flipping through the index of the “R Graphs Cookbook”. There’s a sample chapter available as well, which can help you decide if the book is at the level that you are interested in:

https://www.packtpub.com/sites/default/files/3067OS-Chapter-2-beyond-the-basics-adjusting-Key-Parameters.pdf

In my opinion, the best beginner’s book is “An Introduction to R” by Venables and Smith. A free pdf of the book comes with R, but I recommend purchasing the softcover from Amazon. It is only 115 pages, and someone with STATA experience could easily work through it in on a lazy Saturday or a couple of evenings. It does skim the surface a bit, but for me it provided just enough detail so that I more-or-less understood how R worked and could get started using it right away. My next step was to slowly go through Phil Spector’s “Data Manipulation with R.” The latter book provides more insight into how R handles data. There aren’t many hurdles coming from Stata – I think you will find the language to be easier than Mata/do files and you’ll enjoy having mutiple data sets (dataframes) in memory at once. After that, you might move to one of the subject-area UseR books from Springer (econometrics with R, spatial analysis with R,…). A good choice is one of the books on graphics (either the one on ggplot2 or lattice).

“Using R for Introductory Statistics” by John Verzani is pretty good for a truly introductory textbook. Gets you to a point to reproduce the basic graphs and statistical tests taught in a 101 course.

Thanks for all your suggestions!

My knowledge of SPSS is totally useless, I suppose.

for ecologists – I recommend “the R Book’ by michael J crawley. Its big, and expensive, but very useful and organized in a way that matches a typical ecologists’ workflow. Since my colleague bought it, at least four others in the lab have bought a personal copy.

Haven’t had chance to experiment with R yet, but we are testing our clouded rack and stack data warehouse in the lab at the moment and this looks like the ideal book to give R a whirl.

yes my favorite number is 13

thank you O’Reilly

1st time I hear of “R”, but now I am aware of it and try to do some research on that.

I would also like to put in a plug for my professor’s new book, “Comparing Groups: Randomization and Bootstrap Methods Using R.” My prof at the University of Minnesota, Dr. Andrew Zieffler, and his co-authors Jeffrey Harring, Jeffrey D. Long do a great job making some complex things comprehensible… PS for your context, my favorite number is 3. I’d love to win the R cookbook!!!

yes my favorite number is 23

thank you!!!

I took a graduate course at Ohio State in computational statistics that was based on R and becoming proficient in working with R. The text for that class was “Analyzing Medical Data Using S-PLUS,” which was an expensive Springer-Verlag text. I am finding that “Data Analysis Using Regression and Multilevel/Hierarchical Models” (Gelman & Hill, 2007) is a far more friendly and comprehensive text. I have not worked with the O’Reilly Cookbooks before, but their books which I have used have been excellent.

Oh, I forgot to note that my favorite number is “42”. #hhgttg “Don’t Panic!”

A stats cookbook sounds amazingly useful!

My favorite number is 32

I am a neuroscientist in the Netherlands, though originally from Rome, Italy. Having started analyzing data from an fMRI I asked about the tools of the craft and the division was between 2 matlab toolboxes. Until a guy came to me and showed me magic…in R! That book would be a good step in that direction.

My favourite number is 7 billions, which is the biggest possible N for my experiments.

17!