Re: [R] exit function in R?

2008-06-03 Thread Federico Abascal
Thank everybody for the answers! The stop and quit functions are what I
need (it is a script, not a function what needs to be terminated. I was
talking about an exit function, what can be confusing).

Best,
Federico


Gregory. R. Warnes wrote:

 Since Frederico indeicated he was running a script, rather than a
 function, I suspect that he would be better served by the

 quit(no)

 function.


  Jun 2, 2008, at 5:15PM , Rolf Turner wrote:


 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}}

 __
 R-help@r-project.org mailto:R-help@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.


 Gregory R. Warnes, Ph.D.
 Associate Professor
 Center for Biodefence Immune Modeling
and
 Department of Biostatistics and Computational Biology
 University of Rochester






[[alternative HTML version deleted]]

__
R-help@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.


[R] exit function in R?

2008-06-02 Thread Federico Abascal
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@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.


Re: [R] exit function in R?

2008-06-02 Thread Marc Schwartz

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!
Federico


See ?stop and ?stopifnot

HTH,

Marc Schwartz

__
R-help@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.


Re: [R] exit function in R?

2008-06-02 Thread Markus Schmidberger

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@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

__
R-help@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.


Re: [R] exit function in R?

2008-06-02 Thread Hans-Joerg Bibiko


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

__
R-help@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.


Re: [R] exit function in R?

2008-06-02 Thread Rolf Turner


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}}

__
R-help@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.