rfor-loops

What was a For loop? Why isn't it needed in R?


In the R FAQ's section about comparing S and R, we find the following:

In R, For() loops are not necessary and hence not supported.

What was a For() loop and why does R not need it?


Solution

  • There is a copy of S-PLUS: Programmer’s Guide online. Pages 647-648 contrast for and For loops. The S-Plus manual generally discourages using for loops (pp. 120, 639-641) and encourages apply family approaches, but R has optimized for loops to the point that those recommendations are now moot and the "optimized" For loop is no longer necessary.