ABSTRACT

When the same sequence of commands needs to be applied to different data sets or when an earlier analysis needs to be reproduced, scripts make both implementation and validation of such requirements easy. Related groups of R statements within a script are similar to “paragraphs” while a whole script describing the application of a data processing algorithm to data is similar to an “essay” in natural language. In this chapter you will learn how to write and use R scripts, starting from an extremely simple script and progressing towards more complex ones. Conditional execution of code and iterative loops, which make scripts flexible and reusable, are explained in detail.