How to learn R as a programming language [closed]
Asked Answered
D

4

104

I'd like to know how to learn the R language as as 'programming' language as opposed to learning it as a statistical system. My question is prompted by lack of understanding of such functions as parse, eval, etc. which may not find frequent use by an R user with a 'statistics' persuasion.

Edit: I've been exploring such tools like Rpy RSPerl rJava and wish to (at the very least) be able to understand concepts that facilitate R's communication with other programming languages.

The availability of Web applications for R (R-PHP, RApache, etc.) is another motivationg factor for me to gain a deeper, more structural understanding of R.

Last but not the least, I'd like to be able to write R packages for which such understanding would be beneficial if not necessary.

Dysgraphia answered 16/11, 2009 at 21:7 Comment(6)
You'll get better answers if you can say why you're considering using R as a programming language, rather than a statistical system. Are you gluing together other software, already developed in R? Do you have other programmers who know nothing but R, so you're forced to develop in it?Potluck
There's definitely a need for a book with a title like "Statistical Software Engineering with R", which would explain R from a programming languages point of view, discuss principles of functional programming and object-oriented programming in R, and really focus on best practices for developing relatively large systems.Blueweed
I think this is one of the most fun way to learn this language: tryr.codeschool.com/levels/1/challenges/16Bounder
My vote to reopen is based on the fact that this is a highly upvoted question and in one of the first hits on Google when you search on "stackoverflow r". It is 10 years old and only some of the recommendations are still valid. Furthermore that lack of opportunities to offer more modern material have been shut down.Liquid
@42- you wouldn't consider it a "looking for a tutorial" question?Singe
I would but it is so inaccurate and misleading in its current state that it should either be reopened or deleted completely.Liquid
O
90

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:

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


(source: springer.com)

Orville answered 16/11, 2009 at 21:11 Comment(3)
I was going to answer with the same link. @Dysgraphia Assuming you are not a complete beginner in programming, that link is very useful.Ott
I'm going to also vouch for the R inferno. It contains a lot of what I got out of the Chambers book without the verbosity and religious convictions.Cormorant
The R inferno document is brilliantKoenraad
K
23

A good book for learning R-as-a-programming-language (as opposed to R-for-statistics) is The Art of R Programming, by Norman Matloff.

enter image description here

It's very readable, doesn't assume you're a computer scientist, and is quite inexpensive as R books go.

Kingsbury answered 23/7, 2013 at 2:44 Comment(0)
K
18

I would rather suggest a good and comprehensive start, like The R Book by Michael Crawley. It's an easy-to-read and complete book on R core functions, with statistical tips and a few exercises. It focuses a lot on R strengths (e.g. linear models) and gives also useful coding tricks. It helped me a lot while I was struggling on cryptic online courses.

alt text

Koenraad answered 17/11, 2009 at 10:49 Comment(2)
I agree - this is an excellent introductory book; Crawley writes very clearly.Lees
It's way too detailed. The article by John Cook above is way more concise. As a programmer, you don't need a large part of "The R book".Halette
L
14

I'm a very hands-on learner, so this advice may be specific to my learning style. I would suggest that the best place to start "learning to program" in any language involves finding problems outside of your normal range of experience and then trying to solve them using a programming language.

The projects that taught me the most about how to program with R had nothing to do with statistics at all.

Knowing functions like parse() and eval() is by no means a measure for being "a good R programmer". Applications that require heavy use of these functions do not make up a majority of the problem space in which you can apply R. Instead, I think you should try to be "a good programmer" who knows R. This involves refining your problem-solving approaches.

Programming is not a spectator sport-- a good book is indispensable as a reference on the tools available, but you need to find some problems upon which to hone your skills.

Lifegiving answered 17/11, 2009 at 2:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.