We need functions to avoid the repetitive same few lines of code.
R functions are treated much like any other R objects.
Like in JavaScript language the functions can be passed as arguments and it can be nested too. The functions are defined using the function() directive.
function arguments are another important option for a function.
We can modify our code a bit by setting a default value for the arguments. Therefore we can call the function without passing any argument value to the interface.
Lazy Evaluation
Function arguments are evaluated lazily. The below code example clearly explains it.
When both arguments are used in the body then R will check for the next argument too.
Arguments with ‘…’
In R we can find a special argument … , which indicate a number of arguments that are usually passed on to other functions. The … argument is often used when extending another function.