* Function arguments are always passed by value. Objects are copied if they are modified in a function.
* Function arguments are lazy evaluated.
* Watch out for automatic factor conversion when importing data. R will display your string data as text, but behind the scenes it will treat it as an integer.
* R is slow. Really, really slow. All your intensive calculations should be handled by libraries written in C, Fortran or some other compiled language. Your R code should be mostly for glueing things together.
A couple of examples are stripping the time series attributes of a ts object and default conversion of a row of a matrix to a vector. These are the cases where they come to my office and say they have no idea what's going on. After using R for a decade, I know the language well enough that these are about the only errors I get.
Okay, I'll stop at 1).
Having used R for over 15 years now, the one "feature" which still makes me shake my head is the partial evaluation of function arguments. If function foo has an argument 'blah' and you say foo(bl=5), it'll autocomplete that to 'blah' if there's nothing better to use.
The number of bugs I've found due to that ....
It explains a lot of the quirks.
Hadley's book is a solid introduction when you are trying to map concepts from other, more traditional, programming environments to the R way of thinking.
That was my attempt at a joke. But seriously, I love python when it comes to manipulating data and doing anything statistical. You've got numpy, scipy, scikit-learn, etc.
I'm hoping Julia might become a good alternative to R and Python, but I can't see it catching on in the statistical community anytime soon given how many people are still using relics like SAS and Stata. The raw fact is that statisticians (considered as a group) just aren't very good at programming (and many older statisticians can't program at all), which means that a well-designed programming language may not necessarily be easy to use for a member of the statistical community used to point-and-click statistics suites.
Three aspects of the language that make R particularly well suited for statistical programming are:
1) Missing values built in at a fundamental level.
2) Metaprogramming capabilities. The best way to solve many categories of data analysis problems is to design a domain specific language which allows you to easily combine independent pieces. R's incredible flexibility is great for this.
3) Fundamentally vectorised and functional. This allows you to elegantly express many common data analysis tasks.
I haven't done much with Python, but I don't quite get the same feeling (happy to be told that the reality is otherwise!). For example, the opening line of the installation guide for Pandas doesn't inspire great confidence in me: "The easiest way for the majority of users to install pandas is to install it as part of the Anaconda distribution, a cross platform distribution for data analysis and scientific computing."[1] Do I really need to install the HDF5 package so I can split a concatenated variable into two columns??
[1] http://pandas.pydata.org/pandas-docs/stable/install.html
In a previous life what we did was for every project you'd download a snapshot of an R environment, including all packages. That, and only that, was used for all computation for everything involving that project from start to finish. If Docker was around at the time, that's what we'd have used.
Reproducible computing? The ipython notebook is awesome, though I am not sure if there is anything as good as knitr if your workflow is LaTeX oriented.
R "hands" will usually find Python a backward step when it comes to vectorized data manipulation, but its a forward leap if your data becomes too big or if you have to step out of the comfy environment of exploratory analysis into any form of (even trivial) production settings.
And no you definitely do not need HDF5 to effectively use Pandas.
virtualenv sounds useful. Is it used much when python code is published in a paper?
About HDF5: I was just making the point that the Pandas docs recommend I install Anaconda to get Pandas, thus also installing HDF5. I am sure there are other ways, but the way the documentation is phrased suggests that these other ways are overly difficult.
Edit:knitr not rdoc
disclosure: I work on miniconda. I'm currently working on improving our developer experience. Complaints are welcome.
The other area where Python crushes R is if your data is live streaming. Here you inevitably need a full fledged programming language with proper asynchronous io capabilities and multithreading / multiprocessing that is not batch oriented.
1) An IDE for data analysis/programming: RStudio
2) Easy way to turn your analyses into reports: knitr
3) Easy way to turn your analyses into interactive webapps: shiny
(I also think R wins on visualisation and data manipulation, but I'm biased ;)
I prefer Python myself, but after spending a couple of months with R I do understand why people like it.
(OTOH I'll be a happy person if I never ever have to work with SAS ever again.)
Oops! sorry sorry,... really sorry, apologies for snorting coffee over you, but given multiple years of experience TA'ing for machine learning / datmining courses I couldnt disagree more. R had them in absolute knots, and yeah they were asked to use RStudio if that helped. They struggled with simple things such as writing a naive Bayes classifier. Most of their mistakes were because of R's weird and silent inconsistencies: scalar or vector, copy or reference.
It is possible that all these 30 odd students every year were stupid but chances are fairly low.
EDIT:
The course has since switched to Java (Knime) and Python and that has gone a whole lot smoother.
Neither Java nor Python are my most favorite languages, but have to concede that Python is massively more consistent than R, so a student has to remember less of special cases, and the whipping boy of dearth of packages seemed less real at least in the context of the course. At least in the academic setting enthought / canopy / anaconda does a marvelous job of it.
Instead, learn a native R package like dplyr or data.table that supports all the power of SQL, and is v. v. fast.
likertcat <- c("1"="Not at all", "2"="To a small extent", "3"="To some extent",
"4"="To a moderate extent", "5"="To a large extent")
for(e in names(db[,9:44])) {
db[[e]] <- revalue(db[[e]], likertcat)
db[[e]] <- ordered(db[[e]], levels= c("Not at all","To a small extent",
"To some extent","To a moderate extent","To a large extent"))
} db<-data.frame(replicate(44,1:5))
likertcat <- as.ordered(c("Not at all", "To a small extent", "To some extent",
"To a moderate extent", "To a large extent"))
db[ ,9:44] <- lapply(db[,9:44], function(x) likertcat[x])