Re: [R] How to *completely* stop a script after stop()?

From: Duncan Murdoch <murdoch.duncan_at_gmail.com>
Date: Fri, 08 Apr 2011 13:32:32 -0400

On 08/04/2011 1:29 PM, Jonathan P Daily wrote:
> Would options(error = recover) be of some help?

No, that will probably be very confusing. The problem is that the Windows GUI uses Ctrl-R as a short form of "cut from the editor, paste to the console", and it will paste the whole text regardless of whether it works or not. If recover was triggered, it would be sent the remainder of the script, which would probably lead to a long sequence of errors (recover is looking for an integer).

Duncan Murdoch

> --------------------------------------
> Jonathan P. Daily
> Technician - USGS Leetown Science Center
> 11649 Leetown Road
> Kearneysville WV, 25430
> (304) 724-4480
> "Is the room still a room when its empty? Does the room,
> the thing itself have purpose? Or do we, what's the word... imbue it."
> - Jubal Early, Firefly
>
> r-help-bounces_at_r-project.org wrote on 04/08/2011 12:38:37 PM:
>
> > [image removed]
> >
> > Re: [R] How to *completely* stop a script after stop()?
> >
> > Duncan Murdoch
> >
> > to:
> >
> > algorimancer
> >
> > 04/08/2011 12:40 PM
> >
> > Sent by:
> >
> > r-help-bounces_at_r-project.org
> >
> > Cc:
> >
> > r-help
> >
> > On 08/04/2011 11:47 AM, algorimancer wrote:
> > > I too am encountering this problem. When I have a large script, if I
> select
> > > all in the editor and then ctrl-r to run, if it encounters a stop()
> function
> > > it simply prints an error message and continues to execute the
> remainder of
> > > the script, as opposed to terminating execution at that line. The
> quit()
> > > function exits R altogether, which I don't want. Yes, I could
> manually
> > > select only the portion of script which I want to run, but for lengthy
> > > scripts which I run repeatedly (generally changing only the name of
> the file
> > > I want analyzed), this can be quite tedious. It appears that the only
> > > solution is to put most of the code in a separate file and call it
> using
> > > source(); this has the downside of reducing the clarity of the code --
> it's
> > > a sort-of structural spaghetti code approach.
> >
> > It sounds as though you are talking about the Windows GUI. That's
> > important, because other GUIs probably have different behaviour.
> >
> > To run a script up to the first error, do this:
> >
> > Highlight the part you want to run (or Ctrl-a for everything).
> > Copy the code using Ctrl-c.
> > In the console, run source("clipboard") (perhaps with echo=TRUE if you
> > want to see it as it goes). This is a lot of typing the first time you
> > do it, but after that, the up arrow can bring back the command.
> >
> > It would probably make sense for Ctrl-R to do something functionally
> > equivalent to Ctrl-C, source("clipboard", echo=TRUE) rather than the
> > current behaviour. Not going to happen in 2.13.x, but maybe in 2.14.x
> > in the fall.
> >
> > Duncan Murdoch
> >
> > > --
> > > View this message in context: http://r.789695.n4.nabble.com/How-
> > to-completely-stop-a-script-after-stop-tp3218808p3436704.html
> > > Sent from the R help mailing list archive at Nabble.com.
> > >
> > > ______________________________________________
> > > 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.
> >
> > ______________________________________________
> > 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.
>



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. Received on Fri 08 Apr 2011 - 17:41:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Apr 2011 - 18:00:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive