ABSTRACT

This chapter introduces the fundamentals of programming in R, focused on creating the own custom R functions. Since R provides basic arithmetic capabilities, the simplest—and least useful—approach to computing the Fibonacci numbers would be to use R to implement the brute force computations. The fact that the elements of the vector Fib are given initial values when the vector is created suggests the initialization trick. Given an object of class "AnnotatedGaussianSample," this method extracts the values of the arguments used to set up and call the rnorm function, displays them, and then computes and displays Tukey's five-number summary for the resulting random Gaussian sequence. The other source of data objects available in the body of an R function is free variables, which are variables that are neither passed as arguments in the function call nor created within the body of the function.