Advertisement

Beginning R pp 43-52 | Cite as

Chapter 5: Functional Programming

  • Joshua F. Wiley
  • Larry A. Pace

Abstract

The longer one programs, the easier it becomes to think like a programmer. You learn that the best way to solve a problem is to solve it once in such a way that the adjustments you need to make when the problem changes slightly are very small ones. It is better to use variables and even other functions in your code so that you can change a single value once rather than many times. This is the essence of the pragmatic programmer who writes with purpose. Programmers who come to R from other languages such as C++ or Python tend to think in loops. You are probably convinced by now that R’s vectorization allows us to avoid loops in many situations. As you saw in  Chapter 4, looping is possible when it is needed. Efficient code allows us to automate as many tasks as we can so that we don’t repeat ourselves, and to avoid looping as much as possible.

Keywords

Real Root Free Variable Global Environment Search List Anonymous Function 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Dr. Joshua F. Wiley and the estate of Larry A. Pace 2015

Authors and Affiliations

  • Joshua F. Wiley
    • 1
  • Larry A. Pace
    • 1
  1. 1.IndianaUSA

Personalised recommendations