[R] Using stop ( ) from a Text Editor

Paulo Cardoso pecardoso at netcabo.pt
Mon Jul 28 14:36:40 CEST 2008


> I see no condition object in your example

Isn't if(length(content[content%in%folders])!=4) a condition?

> stop() breaks execution of a block of code that source()d -- maybe that is

what you are looking for?

Yes

> I don't know what you mean by 'TINN' and 'Winedit' (what exact program, 
how are you using them?) but suspect that they are working just like 
pasting lines into the R session, or R-for-Windows' own pager and script 
editor.

A simple search at Google with the keys 'TINN' or 'Winedit' will provide
further information.

Yes. TINN will send the entire lines just like a clipboard paste into R
console

Thanks for your comments.

I think that source() is the way as mentioned by Jim Holtman. Please give-me
some time to clarify my problem with my concrete example.

Paulo Cardoso

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: segunda-feira, 28 de Julho de 2008 13:25
To: Paulo Cardoso
Cc: 'r-help'
Subject: Re: [R] Using stop ( ) from a Text Editor

On Mon, 28 Jul 2008, Paulo Cardoso 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".

I see no condition object in your example.

> This will not be the case when running codes from Winedit or TINN?

Please give us some evidence.  If you run interactively a single statement 
comtaining stop(), it stops execution of just that statement.

>
> 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.

Just as will pasting multiple lines into an interactive R session -- that 
is intentional.

I don't know what you mean by 'TINN' and 'Winedit' (what exact program, 
how are you using them?) but suspect that they are working just like 
pasting lines into the R session, or R-for-Windows' own pager and script 
editor.

> Is there a way to interrupt the code of being read from a text interface?

stop() breaks execution of a block of code that source()d -- maybe that is 
what you are looking for?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
No virus found in this incoming message.
Checked by AVG. 

16:18



More information about the R-help mailing list