ABSTRACT

In R, a function is technically stored in a variable, whose name corresponds to the name of the function. People do not need to put the definition of their function f into a file called f.R. But for functions which are more than a few lines long, it is generally recommended to put the code in a file, for easier editing and debugging. As in many languages, variables defined within a function are only visible within that function, and vanish when the function exits. There are three types of variables that can exist within a function. The first type is a formal parameter, which is a variable defined as an input to the function. The second type is a local variable, i.e., a variable defined inside of the function. The third type is a free variable, which is a variable that is neither a formal parameter nor a local variable.