什么是 For 循环?为什么在 R 中不需要它?

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

the R FAQ's section about comparing S and R中,我们找到以下内容:

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

什么是 For() 循环,为什么 R 不需要它?

网上有一份S-PLUS: Programmer’s Guide。第 647-648 页对比 forFor 循环。 S-Plus 手册通常不鼓励使用 for 循环(第 120、639-641 页)并鼓励 apply 系列方法,但 R 已经优化了 for 循环,以至于这些建议是现在没有实际意义,不再需要“优化”For 循环。