## R Functions

First, we define a function $$f(x,y)=x+2y$$ and play around with it. We assign $$y=1$$ so that we can use either one or two arguments for the function. Note that reassign values of $$x, y$$ won't affect the function in any way. See the following code and output:

Exception handling - first example:

A modified version and output (the case that the file exist)

Anonymous Function

Example: apply function to an array. See the following code and output.

Last modified: Wednesday, 18 June 2014, 9:21 AM