- It takes time. if you've never coded in a real programming language before (SAS and STATA don't count), you may find the learning curve quite steep.
- It may not be worth it. If you're able to do most of the things you need to do using other tools (Excel, SPSS, STATA, etc.), the gains to your productivity may not entirely offset the cost of admission.
If neither of those two points concern you, bravo, you're ready for...
Paul's Practical Advice for Learning R (a step-by-step guide)
Step 1. Get R
Point your browser to http://cran.stat.ucla.edu/, download the appropriate version/binary, and run the installation. Congratulations - you are now well on your way to becoming the next Nate Silver.
Step 2. Get R Studio
While you can certainly use the default R shell (the program that lets you use R), I highly recommend that you get R Studio, a neat little program that wraps itself around the default R shell and offers everything up to you in a clean and informative GUI (graphic user interface). Here is a side-by-side to help motivate your decision:
Step 3. Skim through the official R manual
It's called "An Introduction to R," and it's a surprisingly good one. It can be found here: http://cran.r-project.org/doc/manuals/r-release/R-intro.html. While it's best if you sit down and really work your way through it all, it's probably good enough to read the beginning sections carefully and then skim through the rest. I say this because the next step is...
Step 4. Spend a little money, save a lot of time
It's entirely possible to learn R without spending a cent, but that can be a true pain in the ass as you will end up spending many grief-filled hours cobbling together bits and pieces of R instruction scattered throughout the interwebs (believe me, I've been there). Don't relive my mistakes - nab yourself a good ink-and-paper reference manual to use as your go-to R resource. "But, Paul!" you exclaim, "there are just so many books out there. How do I know which to buy?" Luckily, I've already gone ahead and made all the bone-head purchases, so that you don't have to. Amidst the literal grip of R books stacked on my shelf, I can confidently say you really only need this one:
Step 5. Play with some data; do a data project entirely in R
The quickest way to learn R is to use it... as much as possible. It's that simple. Forget baby steps; that is the quickest way to get discouraged and quit. What you need to do is to commit, heart and soul, to doing a data project entirely in R. An assignment for work or school, ideally, will ensure that you care enough about the project to see it through to the bitter end. And make no mistake: it will be bitter. You will only taste sweet victory after a painfully frustrating struggle that will have you wasting valuable time scouring manuals and googling countless bits of R code and commands, but trust: you will emerge on the other side with a practical mastery of the syntax. And at that point, you will suddenly realize R is fun.
Now if you don't care to risk your job or grades for the sake of learning a statistical programming language (for shame), there are other ways to immerse yourself in the R environment. For example, load up the mtcars data set in R by typing:
(mtcars contains information on 32 models of vehicles with a good mix of both categorical and continuous variables)
When I first began mucking around in R, I made up a wimpy research question to answer using this pre-packaged data set: "What characteristic of these vehicles most significantly affects their mpg ratings?" My goal was to answer that question by a) running a complete set of bivariate tests and plots, and then b) running a full multivariate linear regression model. All of this I could have done in a pinch had I used SAS (my weapon of choice at the time), but I forced myself to do the full analysis entirely in R... and it worked! After several grueling hours, I had finished my mini project and in the process I had somehow attained a working knowledge of R. Things only got easier after that.
I encourage you to try something similar: load up a sample data set, make up a realistic research task, and tackle it head on. The next time you have to do something similar for work or school, you'll be that much more comfortable grinding it through R. This is the only way you will become a regular R user.
The next three steps are subsumed under Step 5. They are meant to help outline good problem-solving habits when you (inevitably) get "stuck."
Step 5a. Love the '?' command
Learn to love the '?' command. Believe it or not, the built-in documentation is pretty good for R. In fact, anytime you need to know what a specific function does, you can pull up a help file on it (complete with examples) by simply typing a question mark in front of the function. For example, if I want help with the 'mean' function, I simply type the following command:
and this is what R spits back:
Step 5b. Use/abuse your R book
Use your copy of R in Action when you get stuck, before you turn to the internet. Science has proven that the solutions to your problems are more likely to stick around in your head if they are associated with the physical act of searching through a text. Also, your R book is not sacred. Highlight, annotate, and bookmark it with reckless abandon; all of that will only serve to further aid your memory.
Step 5c. Consult the online oracles
When all else fails, rely on the internet. The quickest way to get help solving an unsolvable R problem is, of course, to google it; but in case that isn't enough, the following sites provide consistently excellent support:
- UCLA's Institute for Digital Research and Education: R Resource Page - This is an absolute gold mine of example code and easy-to-understand instructions for running all manner of statistical analyses in R and interpreting the outputs.
- Quick-R - Maintained by the author of R in Action, this is a great place to trawl for example code for some of the most common tasks you will perform in R.
- Stack Overflow - This is where you will come for answers to your most noggin-busting problems. In the unlikely event that you can't find the answer to your particular issue in the archives (search tag: [r]), post your question to the boards, and a host of super-friendly nerds will come to your rescue.
Well that's all I got for you, future useR. Best of luck.