[R] how can one break or stop or return from a script?

Stu stu.andrews at gmail.com
Tue Nov 17 22:49:19 CET 2009


Thanks ...
It's good to know I'm not missing the obvious.
- Stu

On Nov 16, 8:31 pm, Don MacQueen <m... at llnl.gov> wrote:
> I don't know how to do this in the way you describe.
>
> Easy alternatives include:
>
>   - putting the part of the script that is to be executed
> conditionally into a separate file, and then source it or not based
> on some condition.
>    - simply wrapping the different parts of the script in if, then, else blocks.
>
> -Don
>
> At 1:37 PM -0800 11/16/09, Stu wrote:
>
>
>
>
>
> >Hi,
>
> >I am using a script to initialize variables in the global workspace.
>
> >Based on some condition, I would like to stop evaluation of a script
> >sourced on the command-line, without issuing an error.
>
> >My current solution is the following hack that uses a repeat { }
> >statement
>
> >----------- init.R -----------
> >#hack to enable setting of breakpoint
> >repeat {
>
> >...
> >if (condition) {
> >     break;
> >}
>
> >...
>
> ># remember to break !!
> >break;
> >} #end repeat
> >EOF
>
> >Thanks,
> >- Stu
>
> >______________________________________________
> >R-h... 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.
>
> --
> --------------------------------------
> Don MacQueen
> Environmental Protection Department
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list