Hi, This is likely an stupid question, but I cannot find the solution. I am searching for an "exit" function, to end the execution of an R script if some condition is not filled. Any clue? Thank you in advance! Federico
try this: stop("Message") warning("Message") Best Markus Federico Abascal schrieb:> Hi, > This is likely an stupid question, but I cannot find the solution. > I am searching for an "exit" function, to end the execution of an R > script if some condition is not filled. > Any clue? > > Thank you in advance! > Federico > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Dipl.-Tech. Math. Markus Schmidberger Ludwig-Maximilians-Universit?t M?nchen IBE - Institut f?r medizinische Informationsverarbeitung, Biometrie und Epidemiologie Marchioninistr. 15, D-81377 Muenchen URL: http://ibe.web.med.uni-muenchen.de Mail: Markus.Schmidberger [at] ibe.med.uni-muenchen.de Tel: +49 (089) 7095 - 4599
on 06/02/2008 08:18 AM Federico Abascal wrote:> Hi, > This is likely an stupid question, but I cannot find the solution. > I am searching for an "exit" function, to end the execution of an R > script if some condition is not filled. > Any clue? > > Thank you in advance! > FedericoSee ?stop and ?stopifnot HTH, Marc Schwartz
On 2 Jun 2008, at 15:18, Federico Abascal wrote:> Hi, > This is likely an stupid question, but I cannot find the solution. > I am searching for an "exit" function, to end the execution of an R > script if some condition is not filled. > Any clue? >f <- function() { ... if (1 == 1) return(WHATEVER) ... ... return(ONSUCCESS) } --Hans
On 3/06/2008, at 1:18 AM, Federico Abascal wrote:> Hi, > This is likely an stupid question, but I cannot find the solution. > I am searching for an "exit" function, to end the execution of an R > script if some condition is not filled. > Any clue?Others have suggested using stop(). It might be the case that the condition not being fulfilled is not actually a sign of an error, but simply of a different, perhaps ``marginal'' situation in which a different sort of action or calculation is required. In which case what you want is return(). Trivial e.g.: foo <- function(x) { if(any(x<=0)) return(42) y <- sum(log(x)) y } cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}