R: Nested Functions

We use nested function to do coding more efficiently as it allows to execute multiple commands at the same time. In complex data science use cases, we may have to work on nested functions.

Nested Function is a function within function.

We use nested function to avoid complexity, rather than assigning values from each step  to a separate variable we can easily nest them into one another.To create a nested function we can replace the variable name with the code on right hand side of assignment operator.


c = 2

f1 = function(a,b)


f2 = function(a,b,c)
    c <<- c     


[1] -2
[1] -3