We teach R because it greatly facilitates data analysis, the main topic
of this book. By coding in R, we can efficiently perform exploratory
data analysis, build data analysis pipelines, and prepare data
visualization to communicate results. However, R is not just a data
analysis environment but a programming language. Advanced R programmers
can develop complex packages and even improve R itself, but we do not
cover advanced programming in this book. Nonetheless, in this section,
we introduce three key programming concepts: conditional expressions,
for-loops, and functions. These are not just key building blocks for
advanced programming, but are sometimes useful during data analysis. We
also note that there are several functions that are widely used to
program in R but that we will not cover in this book. These include
split
, cut
, do.call
, and Reduce
, as well as the data.table
package. These are worth learning if you plan to become an expert R
programmer.