I have an R code which looks like:
func1 = function(a) {
func2 = function(a) {
return(a+2)
}
func3 = function(a) {
return(a+3)
}
return(a+func2(a))
}
Is it possible that I be able to call func2 or func3 from outside func1?
eg. How do I run:
x <- func2(10) #from the console?
You could create a function closure:
You can use the closure to share variables: