[R] Fortune! (Was: How to *completely* stop a script after stop()?)
Achim Zeileis
Achim.Zeileis at uibk.ac.at
Sat Jan 15 23:21:22 CET 2011
On Sat, 15 Jan 2011, Dirk Eddelbuettel wrote:
>
> On 15 January 2011 at 11:29, Carl Witthoft wrote:
> |
> | Somehow this reminds me of a famous FORTRAN code snippet:
> |
> | 10 STOP
> | STOP
> | STOP
> | ! IN CASE STILL SKIDDING
> | GOTO 10
>
> Immediate candidate for the fortunes package!
Thx, added on R-Forge.
Z
> Dirk
>
> | <quote>
> | From: Marius Hofert <m_hofert_at_web.de>
> | Date: Sat, 15 Jan 2011 09:09:20 +0100
> |
> |
> | Dear expeRts,
> |
> | is there a neat way to *completely* stop a script after an error
> | occured? For example, consider the following script:
> |
> | ## ==== file.R ====
> |
> | for(i in 1:10){
> |
> | print(i)
> | if(i == 5) stop("i == 5")
> |
> |
> | }
> | for(i in 11:100) print(i)
> |
> | ## ================
> |
> |
> | stop() behaves like it should namely to stop the execution of the
> | *current* expression, but I was wondering if it is possible to *really*
> | stop the script after the first for loop [so without executing the
> | second for loop or anything after that point]. Of course one could use
> | something like "if(there was an error) do not continue" but that's not
> | really nice.
> |
> | ______________________________________________
> | 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.
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
More information about the R-help
mailing list