"return" function
On Fri, 14 Sep 2001, Chris Marshall wrote:
I tried to write a function like this
f1 <- function(){
if (condition 1) return
if (condition 2) return
...
if (condition 3) return
do more work
}
Where I am using return to exit the function prematurely when I detect
conditions that warrant it. Return doesn't seem to work this way.
How should I do this?
You need to evaluate the function if (condition1) return() if (condition2) return() etc It's the same for all functions -- at the command line, for example, if you type the name of a function without parentheses you just get the source code for the function listed. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._