[R] return from nested function?

Thomas Lumley tlumley at u.washington.edu
Fri Feb 25 21:51:00 CET 2005


On Fri, 25 Feb 2005 jhallman at frb.gov wrote:

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

Not as such. You probably want to signal and catch a condition.  Look at 
?tryCatch.

 	-thomas


> I have a function that lets user make edits to certain objects, and then
> checks that the edited objects still make sense.  If they don't, the function
> puts up a notifier that the edits are being discarded and then returns,
> something like:
>
>   if(badEdits){
>       notifyDialog("bad edits will be ignored")
>       return()
>   }
>   else {
> 	  ## some stuff that assigns the edited objects in the calling frame
>      return()
>   }
>
> This works, but I'd really like to put the return() in the notifyDialog()
> function.  Is there an easy way to do this?
>
> Jeff
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list