What are anonymous function in R?

r

#1

I am currently studying about anonymous function in R.

anonymous function - function that are not named appropriately are known as anonymous function.

While reading I encounter one example. But I am not able to understand it.

evaluate <- function (func , dat){
func(data)
}

evaluate(function(x){x+1}, 6}
7

#2

hi @harry,

Anonymous functions are just functions for which you choose not to give a name.

In the above example the function has no name but is performing the operations.
This is the same as:

f <- function(x) x + 3
f(10) 

btw: It is always a good idea to name your functions!!
Hope this helps!!