[R] Using stop ( ) from a Text Editor

jim holtman jholtman at gmail.com
Mon Jul 28 14:22:32 CEST 2008


If you are using Tinn-R, then I am assuming that you are using the
'send selection' which basically minics the keyboard.  On the
keyboard, after a 'stop' you can type in the next command without any
problems.  Here is a script I was using with Tinn-R:

x <- 1
stop('error')
cat('continue processing')

If I select it and send it to R, here is what I get:

> x <- 1
> stop('error')
Error: error
> print('continue processing')
[1] "continue processing"
>

It executed the 'print' command.  When I send it in as
'source(selection)' the following is the output:

> source(file('clipboard'))
Error in eval.with.vis(expr, envir, enclos) : error
>

Here is did stop the processing of the script.  So if you want it to
stop, 'source' in the script instead of 'typing' it in.

On Mon, Jul 28, 2008 at 7:34 AM, Paulo Cardoso <pecardoso at netcabo.pt> wrote:
> When using stop clause with a condition, its documented that "If a condition
> object is supplied it should be the only argument, and further arguments
> will be ignored, with a warning".
>
> This will not be the case when running codes from Winedit or TINN?
>
> When I do something like:
>
> if(length(content[content%in%folders])!=4) stop("Execution will be
> interrupted")
>
> from TINN while executing an entire code R will continue reading the code
> anyway.
>
> Is there a way to interrupt the code of being read from a text interface?
>
> Paulo
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list