How to Learn R as a Programming Language

How to learn R as a programming language

For starters, you might want to look at this article by John Cook. Also make sure that you read "The R Inferno".

There are many good resources on the R homepage, but in particular, read "An Introduction to R" and "The R Language Definition".

Some very closely related stackoverflow questions:

  • books-for-learning-the-r-language.
  • what-are-some-good-books-web-resources-and-projects-for-learning-r
  • suggestions-on-way-resources-to-start-learning-statistical-language-r

My favorite book on the subject: "Software for Data Analysis: Programming with R", by John Chambers, the creator of the S language.

Learning R. Where does one Start?

Completely biased response: learn plyr, reshape2 and ggplot2. They will cover 90% of your data manipulation and visualisation needs. All three packages have a consistent philosophy of data (which the ggplot2 book touches upon), and are designed to be consistent and easier to
learn.

Rather than learning many specialised functions, I really encourage you to learn about simple functions that can be flexibly composed to solve a wide range of problems. This is what plyr strives to do for data manipulation, and what ggplot2 strives to do for visualisation. It does mean you need to invest more time up front to learn a little about the underlying theory, but it's my belief that it will pay off handsomely in the long run.

Structure of an R course for beginners

The number one thing you want to do in any short course is get students interested and motivated - you can convey very little information in 3-4 hours, but you can motivate your students to learn more. I'd recommend picking one topic of interest to your community and showing them how R can help them kick butt in that area. Cut ruthlessly - you want to figure out the absolute minimum path from knowing nothing about R to being able to do something useful, something that makes your students say "wow, that's cool". For me, I use graphics - in 3 hours you can teach the basics of ggplot2 (scatterplots, histograms, aesthetics and facetting) giving students a powerful toolkit for data exploration.

I would recommend using RStudio. I wouldn't recommend talking about code style, vectorisation, or probably even for loops.

C for R programmers - recommended resources/approaches once past the basics

I have struggled with this issue as well.

If the issue is to improve command of C, there are plenty of book lists on the subject. They all start with K&R. I enjoyed "Expert C Programming" by P. van der Linden and "C primer" by S. Prata. Any reference on the C standard library works.

If the issue is to interface C to R, other then the aforementioned official R document, you can check out this Harvard course, and this quick start guide. I have only passed scalar and arrays to C, and honestly wouldn't know how to interface complex data structures.

If the issue is to interface C++ to R, or build C++ skills, I can't really answer as I don't use much C++. A good starting point for me was "C++ the Core Language" (O'Reilly). Very simple, primitive, but useful for people coming from C.

Programming language to process large data for R

I don't really like having too many tools in a workflow. If I can get away with just using R, I prefer that. You either end up having to manually run a few tools in series, which makes it more work to run again. Or you spend time interfacing the different tools, which takes time and introduces its own set of problems.

For a beginning programmer, just sticking with R has another advantage: you spend all your time learning one language, i.e. preventing being a jack of all trades but master of none.

I use several programming languages next to each other (R, Python, IDL, Fortran), but for data processing I tend to want to stick to pure R if I can help it.

How to create the best Interactive R Language Online Learning Platform from the views of R community?

It would probably be much more resource intensive and require more effort to create, but check this out: I found Code Academy to be a fun way to tinker with JavaScript. Unfortunately the site is (so far) only for a single language and a closed-source, venture-backed startup.

The main problem is that Rweb (as I am learning right now) does execute everything in batch, so this interpreted line-by-line approach used in CA probably cannot be done with it. If you were to create a similar app to CA for R, you'd have to open an R session for every user, hence the resource intensiveness disadvantage stated above. Hope this can be overcome, maybe someone will have an idea.

Hope you find this useful, at least as an inspiration for your endeavors. I wish you the best of luck.

What are some good books, web resources, and projects for learning R?

This is essentially a dump of my bookmarks, and what I have on my desk.

Getting started:

  1. A tutorial video on R
  2. John Cook's introduction to R for programmers
  3. R reference card
  4. Interactive tutorial: Introduction to R

Advanced:

  1. The R-Gallery
  2. The R Wiki
  3. Quick-R on advanced statistics

Books:

  1. The R Book (Covers the basics, classical statisitical tests, basic statistical modeling (ANOVA, ANCOVA, GLM, non-linear models, etc.), advanced statistical modeling (tree models, time-series analysis, spatial statistics, survival analysis, simulation), and twiddling with the graphics output.
  2. R Graphics (How to make R graphics look sharp)

Common R idioms

I would primarily recommend the R Inferno. In particular, study section 3 on vectorization, which is probably the key concept in R programming.

Beyond that, I would second Dirk's recommendation of John Chambers book.

Going a step farther: the R language is derived primarily from Scheme. One of the best ways to deeply understand R programming (as compared to a language like Java or C) is by learning about functional programming. For this, the best resource might be SICP (the "Structure and Interpretation of Computer Programs", available free online) which uses Scheme. You can find the relevant video lectures online as well: MIT 6.001 and Berkeley 61a.



Related Topics



Leave a reply



Submit