4  functions.r

Some of the code we develop below can be reused later. For that reason, we collect all the useful functions into a R source file called functions.r and include that into our code with source('functions.r'). It has to be in the same folder as the source code as used here, but you can keep it anywhere you want, just adjusting the path in source().