[R] return from nested function?

Seth Falcon sfalcon at fhcrc.org
Wed Mar 2 08:21:44 CET 2005


On Feb 25, 2005, at 12:34 PM, jhallman at frb.gov wrote:

> Is is possible from within a function to cause its caller to return()?

This snippet may be of interest:


 > f = function(x) {
+ print("f")
+ g(return())
+ print("end of f")
+ }

 > g=function(x) {print("g")
+ x
+ print("end of g")
+ }

 > f(1)
[1] "f"
[1] "g"
NULL




More information about the R-help mailing list