Control structures in R
R has the appearance of a procedural programming language. However, it is built on another language, known as S programming language. S leans towards functional programming. It also has some object-oriented characteristics. This means that there are many complexities in the way that R works.
In this section, we will look at some of the fundamental building blocks that make up key control structures in R, and then we will move onto looping and vectorized operations.
Assignment operators
R has five assignment operators, which are listed here:
<-
->
=
<<-
->>
In this book, we will use the following assignment operator:
<-
We will use this assignment operator here, because it is used commonly in examples on well-known internet sites such as StackOverflow (http://stackoverflow.com/). It's also possible to use the rightward assignment operator, but that is confusing for many people so it is not used here. Note also that the equals sign isn't used here...