R, the master troll of statistical languages (2012)
<i>The upshot is that unless you carefully read the apply() documentation..., you’re hosed.</i><p>One thing that jumps out at me, having returned to R after several years in the Python world, is how obtuse its documentation can be.<p>The standard format for R documentation does a few things that I find impede understanding.  First, the help pages are organized into sections giving the high-level description, the arguments, the details, and the results (&quot;values&quot;).  The &quot;details&quot; generally are organized by argument keyword, and the arguments section draws on the language laid down-- usually in a vague, high-level way-- by the description section.  Finally the practical effects of the details are deferred till the results section.  That means unless you already know what&#x27;s going on, you end up having to jump around among sections, trying to synthesize everything.<p>This is particularly a problem for those help pages-- and there are a lot of them-- that describe a raft of related functions all at the same time.  Describing a bunch of related functions in the same place sounds like a good idea (it should help you figure out `apply` vs `sapply`, right?).  Yet this is exactly when the documentation organization results in the most scattershot reading, because in addition to having to synthesize between sections, you have to mentally prune away text that, for one reason or another, doesn&#x27;t apply to your particular case (for example, because different functions don&#x27;t all share the same arguments, or because you want to read about the values for just one variation on the function).<p>Another idiom I dislike in the standard R documentation is how the examples don&#x27;t actually show any sample output.  There are generally some attempts at comments to explain what the sample code should or shouldn&#x27;t do, but they are very much written in the style of programmer&#x27;s comments, not in the style of documentation or learning points.  So you end up having to run the code, and sometimes puzzle over the results for a while.<p>Here&#x27;s an example, from the help page that I happen to have open right now, `help(sample)`:<p><pre><code>     # sample()&#x27;s surprise -- example
     x &lt;- 1:10
         sample(x[x &gt;  8]) # length 2
         sample(x[x &gt;  9]) # oops -- length 10!
         sample(x[x &gt; 10]) # length 0
</code></pre>
The comments alert me that there&#x27;s a &quot;surprise&quot; in store, and they even allude to the (apparently surprising) fact that the second line produces a 10-vector.  Notably lacking is any explanation of what&#x27;s meant to be surprising here, how that relates to the internal logic of `sample`, or how to avoid falling into the trap.<p>Overall, I feel like R&#x27;s documentation is a bit like a conversation among experts, with a rather sink-or-swim attitude towards newcomers.<p>Documentation is far from the first thing that stands out about R vs Python, but it&#x27;s the most salient, I think, in the context of the original article.