I'm learning R programming. I'm unable to understand how function within function works in R. Example:
f <- function(y) {
function() { y }
}
f()
f(2)()
I'm not able to understand why $f() is not working and showing following message:
function() { y } <environment: 0x0000000015e8d470>
but when I use $f(4)() then it is showing answer as 4. Please explain your answer in brief so that I can understand it easily.
f <- function(y) { (function() { y })() }
though that's just equivalent tof <- function(y){y}
– alistaire Dec 4 '16 at 21:10