February 7, 2013 9:54 AM Subscribe

StatFilter: Would anybody be able to recommend a good introduction to the statistical computing language "R" that a reasonably quantitatively-adept psychologist might be able to work through on his own? Something like a step-by-step book or textbook with exercises would be great to help me become more fluent in R. (My colleagues at work who use R are primarily computer scientists who either first learned MatLab or are brilliant autodidacts when it comes to learning different scripting languages, and thus don't have any suggestions; Googling has mostly proferred a somewhat obscurely structured guide from the R authors and lots of invocations to just learn on my own, somehow...). I've become familiar with how to do many individually useful tasks in data structuring and analysis, but I feel a bit like a very high-functioning tourist who has learned a lot of phrases to get around but who would be lost and mugged in an alleyway if I strayed off the beaten path.

posted by Keter to Computers & Internet (16 answers total) 94 users marked this as a favorite

posted by Keter to Computers & Internet (16 answers total) 94 users marked this as a favorite

This blog post from today has some good suggestions for both online and offline learning. If you are interested in brushing up on statistics at the same time as learning R, then I would say Crawley's *Statistics: An Introduction using R* is very good.

But if you're already very solid statistically, and just want help with R, then you could also do worse than use the site Quick-R. It's not exhaustive, but it covers 80% of the stuff you're likely to need in 20% of the space as other presentations.

posted by muhonnin at 10:04 AM on February 7, 2013 [3 favorites]

But if you're already very solid statistically, and just want help with R, then you could also do worse than use the site Quick-R. It's not exhaustive, but it covers 80% of the stuff you're likely to need in 20% of the space as other presentations.

posted by muhonnin at 10:04 AM on February 7, 2013 [3 favorites]

Once you get the very basics, I really like The R-Cookbook which has section titles like "forming a confidence interval for a mean" or "reading from CSV files." Here is handy website which also shows you how to do a bunch of basic tasks.

posted by shothotbot at 10:14 AM on February 7, 2013 [2 favorites]

posted by shothotbot at 10:14 AM on February 7, 2013 [2 favorites]

Do you want to be able to *use* R, or be able to fully code in it?

If you just want to be able to use it, you can download the add-on R-Cmdr (R Commander), which is a menu-driven interface.

posted by entropone at 10:42 AM on February 7, 2013 [1 favorite]

If you just want to be able to use it, you can download the add-on R-Cmdr (R Commander), which is a menu-driven interface.

posted by entropone at 10:42 AM on February 7, 2013 [1 favorite]

I've seen people use R in several different ways. One way is to use "cookbook" approaches for reading, cleaning up, and organizing the data, followed by whatever analysis is desired. This is the cookbook approach.

The second approach is to use R as an actual scripting/programming environment, which requires learning to identify and use basic control statements (loops, conditionals), variables and scope, writing functions, working with R objects (which are fairly rudimentary).

For the second approach, I recommend Introduction to Scientific Programming and Simulation Using R, which is just a basic book on R programming, with minimal coverage of statistics. (I am assuming you already know what kinds of statistical models you want to make.)

One word of caution is that, being a very extendable language with lots of user-submitted code packages, R is somewhat inconsistent in its notation and naming conventions, and a little too lazy with throwing errors (e.g., if you use an index that's out of range for a numeric array, R will silently extend the array for you).

posted by Nomyte at 11:00 AM on February 7, 2013 [1 favorite]

The second approach is to use R as an actual scripting/programming environment, which requires learning to identify and use basic control statements (loops, conditionals), variables and scope, writing functions, working with R objects (which are fairly rudimentary).

For the second approach, I recommend Introduction to Scientific Programming and Simulation Using R, which is just a basic book on R programming, with minimal coverage of statistics. (I am assuming you already know what kinds of statistical models you want to make.)

One word of caution is that, being a very extendable language with lots of user-submitted code packages, R is somewhat inconsistent in its notation and naming conventions, and a little too lazy with throwing errors (e.g., if you use an index that's out of range for a numeric array, R will silently extend the array for you).

posted by Nomyte at 11:00 AM on February 7, 2013 [1 favorite]

I know Try R was floating around a while ago, though I haven't tried it. It seems to be something like a codecademy-style step-by-step walkthrough of the language.

posted by zempf at 11:04 AM on February 7, 2013

posted by zempf at 11:04 AM on February 7, 2013

I quite liked this O'Reilly Code School introduction

http://tryr.codeschool.com/

...gets you through the practical concepts, mentions pirates frequently.

posted by bendybendy at 11:04 AM on February 7, 2013 [1 favorite]

http://tryr.codeschool.com/

...gets you through the practical concepts, mentions pirates frequently.

posted by bendybendy at 11:04 AM on February 7, 2013 [1 favorite]

You're in psychology and this book is geared towards biology, but I found it helpful and it might be worth looking into: Getting Started with R

posted by lucy.jakobs at 11:16 AM on February 7, 2013

posted by lucy.jakobs at 11:16 AM on February 7, 2013

I was also going to mention the CodeSchool course.

R TwoTutorials is a set of two-minute videos on random 'how to do x in R' topics. Not sure if it is quite what you are looking for.

I just took the Coursera Computing for Data Analysis course, an intro to R. They may run it again in a few months, and it sounds like pretty much what you want.

From there, a selection of books and links that I copied out of the wiki (because I think I'll lose access to it):

Links to sites with tricks, tutorials and helpful articles, provided by various users on the discussion forum.

Cookbook for R

Quick R

100 most read R posts on R-statistics.com

R Twotorials

R Tutorial

An introduction to R

R style guide

R tutor

Try-R. A free self-paced introductory R course from CodeSchool.com.

Archive for datasets bundled with R

R-bloggers R news and tutorials sourced from over 400 R bloggers.

CRAN Packages List of R ve Network (CRAN).

Aprenda a usar o R Tutorial in portuguese

R Quick Reference Card

Books

Provided by various users on the discussion forum and taken from the last slide in the 'Overview and history of R' lecture.

Braun, W. John, and Duncan J. Murdoch. 2008. A First Course in Statistical Programming with R. 1st ed. Cambridge University Press.

Burns, Patrick. 2011. The R Inferno, this is a free PDF download.

Chambers (2008). Software for Data Analysis, Springer.

(your textbook) Chambers (1998). Programming with Data, Springer.

Conway & White. (2012). Machine Learning for Hackers, O'Reilly

Hastie & Tibshirani & Friedman (2011) The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd edition, Spring. The book can be downloaded for free from the supplied link, R code is also available.

Kabacoff, Robert. 2011. R in Action. 1st ed. Manning Publications. Publishers site has two free sample chapters and source code available as downloads - may have to register first.

Matloff, Norman. 2011. The Art of R Programming: A Tour of Statistical Software Design. 1st ed. No Starch Press.

Murrell (2005). R Graphics, Chapman & Hall/CRC Press. The book's web page has three free chapters (PDF) and the R source for all the diagrams used in the book.

Pinheiro & Bates (2000). Mixed-Effects Models in S and S-PLUS, Springer.

Sakar, Deepayan. Lattice: Multivariate Data Visualization with R, Springer. This site has all the figures and the code to generate them from the book.

Venables & Ripley (2002). Modern Applied Statistics with S, Springer.

Venables & Ripley (2000). S Programming, Springer.

Yau, Nathan (2011), Visualize This: The FlowingData Guide to Design, Visualization, and Statistics, Wiley. There is a blog associated with this book dedicated to data visualisation, it has some stunning graphs and data representation diagrams.

Springer has a series of books called Use R!.

A longer list of books is at available at R-project.org

posted by jacalata at 11:21 AM on February 7, 2013 [10 favorites]

R TwoTutorials is a set of two-minute videos on random 'how to do x in R' topics. Not sure if it is quite what you are looking for.

I just took the Coursera Computing for Data Analysis course, an intro to R. They may run it again in a few months, and it sounds like pretty much what you want.

From there, a selection of books and links that I copied out of the wiki (because I think I'll lose access to it):

Links to sites with tricks, tutorials and helpful articles, provided by various users on the discussion forum.

Cookbook for R

Quick R

100 most read R posts on R-statistics.com

R Twotorials

R Tutorial

An introduction to R

R style guide

R tutor

Try-R. A free self-paced introductory R course from CodeSchool.com.

Archive for datasets bundled with R

R-bloggers R news and tutorials sourced from over 400 R bloggers.

CRAN Packages List of R ve Network (CRAN).

Aprenda a usar o R Tutorial in portuguese

R Quick Reference Card

Books

Provided by various users on the discussion forum and taken from the last slide in the 'Overview and history of R' lecture.

Braun, W. John, and Duncan J. Murdoch. 2008. A First Course in Statistical Programming with R. 1st ed. Cambridge University Press.

Burns, Patrick. 2011. The R Inferno, this is a free PDF download.

Chambers (2008). Software for Data Analysis, Springer.

(your textbook) Chambers (1998). Programming with Data, Springer.

Conway & White. (2012). Machine Learning for Hackers, O'Reilly

Hastie & Tibshirani & Friedman (2011) The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd edition, Spring. The book can be downloaded for free from the supplied link, R code is also available.

Kabacoff, Robert. 2011. R in Action. 1st ed. Manning Publications. Publishers site has two free sample chapters and source code available as downloads - may have to register first.

Matloff, Norman. 2011. The Art of R Programming: A Tour of Statistical Software Design. 1st ed. No Starch Press.

Murrell (2005). R Graphics, Chapman & Hall/CRC Press. The book's web page has three free chapters (PDF) and the R source for all the diagrams used in the book.

Pinheiro & Bates (2000). Mixed-Effects Models in S and S-PLUS, Springer.

Sakar, Deepayan. Lattice: Multivariate Data Visualization with R, Springer. This site has all the figures and the code to generate them from the book.

Venables & Ripley (2002). Modern Applied Statistics with S, Springer.

Venables & Ripley (2000). S Programming, Springer.

Yau, Nathan (2011), Visualize This: The FlowingData Guide to Design, Visualization, and Statistics, Wiley. There is a blog associated with this book dedicated to data visualisation, it has some stunning graphs and data representation diagrams.

Springer has a series of books called Use R!.

A longer list of books is at available at R-project.org

posted by jacalata at 11:21 AM on February 7, 2013 [10 favorites]

I think these are all good suggestions, but for a psychologist there's no better book than Andy Field's Discovering Statistics using R. It's an R version of his book on Discovering Stats using SPSS which was famous when I was in grad school in psychology (it's lighter on theory and heavier on how to actually do the stats with data).

posted by Smegoid at 12:37 PM on February 7, 2013 [3 favorites]

posted by Smegoid at 12:37 PM on February 7, 2013 [3 favorites]

A few more suggestions / votes:

posted by mixing at 1:53 PM on February 7, 2013

- The Braun & Murdoch book
*A First Course in Statistical Programming with R*gives a really nice coverage of fundamentals, so it's definitely worth the read. - Venables & Ripley,
*Modern Applied Statistics with S*is a classic. It's not a good one to start with, because it is very dense (e.g., it covers factor analysis in about 5 pages), but it's a great place to go looking for specific solutions. - Dalgaard's Introductory Statistics with R is pretty good, I think.
- The Fox & Weisberg book Companion to Applied Regression is one of my favourites. It gives a very readable introduction to linear models in R, and is very strong on things like regression diagnostics.
- If you're at all interested in psychometrics, William Revelle's forthcoming book An introduction to psychometric theory with applications in R is good.
- If you're interested in Bayesian methods, then John Kruschke's Doing Bayesian Data Analysis might be a good place to start, as it focuses heavily on R and WinBUGS.
- I'm not personally a fan of the Andy Field books, but a lot of people really like them, and his
*Discovering Statistics Using R*does have the advantage of being a book that starts with the basics and goes all the way up to mixed models. - As an alternative free resource that I'm a little ambivalent about, the course notes that I referred to in this AskMe are available as a free PDF here. The coverage is probably a little basic for your purposes: it only goes as far as multiple regression and factorial ANOVA on the stats side, but it does cover introductory scripting and data manipulation. It has the advantages and disadvantages of being written for psych undergrads: it tries to start from an assumption of no background knowledge which can be useful, but it is tediously slow in places if you already know what you're doing. (btw: I wasn't sure if including this one violates self-linking prohibitions, but this MeTa seems to suggest it's okay if the link is relevant and fully disclosed. If it's not, my apologies.)

posted by mixing at 1:53 PM on February 7, 2013

Wow! Thanks for the overwhelmingly rich responses, everyone! If I can't improve my knowledge of R now, I have noone to blame but myself. :)

posted by Keter at 3:12 PM on February 7, 2013

posted by Keter at 3:12 PM on February 7, 2013

I'm in the same boat, but with even less experience of R. I needed a thing that only R could do, so here I am. In the graphics dept, I discovered this site http://rweb.stat.ucla.edu/ggplot2/, which has a web demo of the graphics package ggplot2. You can play with data and get graphs and such, from a point and click interface, but it also spits out the code at another bottom panel, which I think is a great way to learn.

posted by dhruva at 10:54 AM on February 8, 2013

posted by dhruva at 10:54 AM on February 8, 2013

The is.R() blog is not strictly introductory, but it illustrates (with self-contained code) a wide variety of things you might want to do with R, especially with R graphics. You can just scroll through until you see something similar to what you'd like to do, and then apply the examples to your own data.

posted by rapidadverbssuck at 10:42 AM on February 9, 2013

posted by rapidadverbssuck at 10:42 AM on February 9, 2013

I don't know if you're still checking this thread, but here are a couple of point and click GUIs for R, especially ggplot2;

1. Deducer. This is awesome. You do your graph, and it spits out the code, so you can check it out.

2. R Commander (Rcmdr) plugin called RcmdrPlugin.KMggplot2

posted by dhruva at 5:32 PM on April 11, 2013 [1 favorite]

1. Deducer. This is awesome. You do your graph, and it spits out the code, so you can check it out.

2. R Commander (Rcmdr) plugin called RcmdrPlugin.KMggplot2

posted by dhruva at 5:32 PM on April 11, 2013 [1 favorite]

This thread is closed to new comments.

There's also R for SPSS and SAS Users, which may not apply to you, but has proved useful to people I know who primarily used SPSS but wanted some analysis that wasn't easy to do with it.

posted by holgate at 10:01 AM on February 7, 2013