[R] how to abort script with message

Henrik Bengtsson hb at stat.berkeley.edu
Mon May 21 22:22:57 CEST 2007


Hi,

I think the behavior that you outline is due to the fact that you
cut'n'paste the script to the R prompt, is that correct? If so, use
source() instead to run your script, then stop() will do what you
want.

/Henrik

On 5/21/07, Blew, Ted <TBlew at ets.org> wrote:
> it is desired to abort an R script with a message, returning to the R
> prompt,
> pending 'if' results, as follows:
> ------------------------
> first part of script
> .
> .
> if (condition) {
>  action
> } else
> {
> 'error'
> abort
> }
> .
> .
> remainder of script
> ---------------------------
>
> note: 'stop' aborts the current script expression but keeps running the
> script.[too little]
>         'quit' aborts the r session. [too much]
> thx,
> ted
>
>
>
>
> --------------------------------------------------
> This e-mail and any files transmitted with it may contain privileged or confidential information.
> It is solely for use by the individual for whom it is intended, even if addressed incorrectly.
> If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute,
> or take any action in reliance on the contents of this information; and delete it from
> your system. Any other use of this e-mail is prohibited.
>
> Thank you for your compliance.
> --------------------------------------------------
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list