Chapter 7. Basic Programming
In the previous chapters, we explored the basic aspects of how R stores information and the different ways to organize information. We will now explore the way that operations can be defined and executed, and write a program in R. The ability to create algorithms that combine functions to complete complicated tasks is one of R's best features. We continue the exploration of programming in the next two chapters and focus on object-oriented approaches. This chapter is divided into four parts:
- Conditional execution: In this section, we will introduce if-then-else blocks and discuss logical operators
- Loop constructs: In this section, we will explore three different ways to implement loops
- Functions: In this section, we will discuss how to define functions in R and explore some of the important considerations associated with functions
- Script execution: In this section, we will discuss how to execute a set of commands that have been saved in a file